From a8a31a22fa195d4ee6d3fe990acd73fa48841edf Mon Sep 17 00:00:00 2001 From: Elfi0Kuhndorf <93766359+Elfi0Kuhndorf@users.noreply.github.com> Date: Fri, 16 Feb 2024 14:08:19 +0100 Subject: [PATCH 01/20] MTT-7858: Make ParrelSync window interactable in tutorial (#155) * change the masking settings of that tutorial page so that users can use the ParrelSync window * Revert "change the masking settings of that tutorial page so that users can use the ParrelSync window" This reverts commit 86fe3b2553301da224e7809f0d96db57fc73c5ee. * add parrelsync clones window to tutorial --- .../50-TestNetworkBehaviour.asset | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Experimental/MultiplayerUseCases/Assets/Editor/Tutorials/NetworkVariablesVsRPC/50-TestNetworkBehaviour.asset b/Experimental/MultiplayerUseCases/Assets/Editor/Tutorials/NetworkVariablesVsRPC/50-TestNetworkBehaviour.asset index 1521453a..a4af59fe 100644 --- a/Experimental/MultiplayerUseCases/Assets/Editor/Tutorials/NetworkVariablesVsRPC/50-TestNetworkBehaviour.asset +++ b/Experimental/MultiplayerUseCases/Assets/Editor/Tutorials/NetworkVariablesVsRPC/50-TestNetworkBehaviour.asset @@ -78,6 +78,18 @@ MonoBehaviour: m_MaskType: 0 m_MaskSizeModifier: 0 m_UnmaskedControls: [] + - m_SelectorType: 1 + m_ViewType: + m_TypeName: UnityEditor.Toolbar, UnityEditor.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + m_EditorWindowType: + m_TypeName: ParrelSync.ClonesManagerWindow, ParrelSync, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + m_AlternateEditorWindowTypes: + m_Items: [] + m_MaskType: 0 + m_MaskSizeModifier: 0 + m_UnmaskedControls: [] m_Summary: m_Description: m_InstructionBoxTitle: From 66e05ca1c03a633da49225e41fb9eb3829d55e87 Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Thu, 14 Mar 2024 13:24:11 -0400 Subject: [PATCH 02/20] feat: dotnet standards tests + formatting pass on samples [MTT-5183] (#156) * standards job added per sample project * indentation * descriptive job name per project * relative path to projects * editorconfig added * actual netcode standards csproj file * removing test job, paths sorted * Invaders formatted * 2DSpaceShooter formatted * ClientDriven formatted * DynamicAddressablesNetworkPrefabs formatted * MultiplayerUseCases formatted * changelog addition * test: update editorconfig * line separators change * file in Addressables project formatted * formatted straggler scripts in invaders --- .editorconfig | 200 ++++++++ .yamato/build.yml | 1 + .yamato/project-standards.yml | 22 + .yamato/project.metafile | 2 +- .../2DSpaceShooter/Assets/Scripts/Asteroid.cs | 16 +- Basic/2DSpaceShooter/Assets/Scripts/Bullet.cs | 2 +- .../Assets/Scripts/NetworkManagerHud.cs | 62 +-- .../2DSpaceShooter/Assets/Scripts/Powerup.cs | 26 +- .../Scripts/RandomPositionPlayerSpawner.cs | 8 +- .../Assets/Scripts/ShipControl.cs | 98 ++-- .../2DSpaceShooter/Assets/Scripts/Spawner.cs | 22 +- .../Scripts/ClientObjectWithIngredientType.cs | 6 +- .../Assets/Scripts/ClientPlayerColor.cs | 2 +- .../Assets/Scripts/ClientPlayerMove.cs | 4 +- .../ClientDriven/Assets/Scripts/HostJoinUI.cs | 22 +- Basic/ClientDriven/Assets/Scripts/ScoreUI.cs | 6 +- .../Assets/Scripts/ServerIngredient.cs | 2 +- .../Assets/Scripts/ServerIngredientPhysics.cs | 4 +- .../Assets/Scripts/ServerPlayerMove.cs | 10 +- .../Assets/Scripts/ServerPlayerSpawnPoints.cs | 2 +- .../Assets/Scripts/ServerScoreReplicator.cs | 2 +- .../Editor/StarterAssetsDeployMenu.cs | 24 +- .../ThirdPersonStarterAssetsDeployMenu.cs | 8 +- .../InputSystem/StarterAssetsInputs.cs | 116 ++--- .../CanvasInputs/UICanvasControllerInput.cs | 2 +- .../MobileDisableAutoSwitchControls.cs | 4 +- .../Scripts/VirtualInputs/UIVirtualButton.cs | 2 +- .../VirtualInputs/UIVirtualJoystick.cs | 28 +- .../VirtualInputs/UIVirtualTouchZone.cs | 18 +- .../Scripts/BasicRigidBodyPush.cs | 50 +- .../Scripts/ThirdPersonController.cs | 6 +- .../Scripts/00_Preloading/Preloading.cs | 12 +- .../ConnectionApproval.cs | 54 +-- .../ServerAuthoritativeLoadAllAsync.cs | 64 +-- .../ServerAuthoritativeSynchronousSpawning.cs | 88 ++-- ...rAuthoritativeNetworkVisibilitySpawning.cs | 88 ++-- .../05_API Playground/APIPlayground.cs | 156 +++--- .../Scripts/Readme/Editor/ReadmeEditor.cs | 10 +- .../Assets/Scripts/Shared/AddressableGUID.cs | 2 +- .../Assets/Scripts/Shared/AppController.cs | 20 +- .../Scripts/Shared/ConnectionPayload.cs | 2 +- .../Assets/Scripts/Shared/ConnectionState.cs | 4 +- .../ConnectionStates/ClientConnectedState.cs | 4 +- .../ConnectionStates/ClientConnectingState.cs | 18 +- .../ConnectionStates/ClientPreloadingState.cs | 2 +- .../Shared/ConnectionStates/HostingState.cs | 4 +- .../Shared/ConnectionStates/OfflineState.cs | 2 +- .../ConnectionStates/StartingHostState.cs | 6 +- .../Shared/DynamicPrefabLoadingUtilities.cs | 38 +- .../Shared/OptionalConnectionManager.cs | 32 +- .../Assets/Scripts/UI/IPMenuUI.cs | 14 +- .../Assets/Scripts/UI/InGameUI.cs | 16 +- Basic/Invaders/Assets/Scripts/EnemyAgent.cs | 4 +- Basic/Invaders/Assets/Scripts/EnemyBullet.cs | 2 +- Basic/Invaders/Assets/Scripts/InvadersGame.cs | 92 ++-- Basic/Invaders/Assets/Scripts/LobbyControl.cs | 8 +- Basic/Invaders/Assets/Scripts/MenuControl.cs | 2 +- Basic/Invaders/Assets/Scripts/PlayerBullet.cs | 8 +- .../Invaders/Assets/Scripts/PlayerControl.cs | 12 +- .../Assets/Scripts/SceneTransitionHandler.cs | 16 +- Basic/Invaders/Assets/Scripts/Shield.cs | 2 +- .../Assets/Scripts/SuperEnemyMovement.cs | 4 +- CHANGELOG.md | 7 + .../Scripts/MultiplayerUseCasesUtilities.cs | 2 +- .../Assets/Common/Scripts/NetworkManagerUI.cs | 4 +- .../Assets/Common/Scripts/PlayerManager.cs | 2 +- .../Editor/Tutorials/TutorialCallbacks.cs | 4 +- .../InputSystem/StarterAssetsInputs.cs | 116 ++--- .../Scripts/BasicRigidBodyPush.cs | 50 +- .../Scripts/ThirdPersonController.cs | 4 +- .../Tests/Editor/MissingReferencesFinder.cs | 4 +- .../Assets/Tests/Editor/ProjectTests.cs | 2 +- .../NetvarVsRpc/Scripts/ColorManager.cs | 2 +- .../Scripts/CharacterManager.cs | 2 +- .../NetworkVariables/Scripts/ColorManager.cs | 2 +- .../Scripts/SceneSelectionElement.cs | 2 +- .../Scripts/SceneSelectionUI.cs | 2 +- dotnet-tools/.gitignore | 454 ++++++++++++++++++ dotnet-tools/README.md | 61 +++ dotnet-tools/netcode.standards/Program.cs | 66 +++ .../netcode.standards.csproj | 15 + 81 files changed, 1595 insertions(+), 769 deletions(-) create mode 100644 .editorconfig create mode 100644 .yamato/project-standards.yml create mode 100644 dotnet-tools/.gitignore create mode 100644 dotnet-tools/README.md create mode 100644 dotnet-tools/netcode.standards/Program.cs create mode 100644 dotnet-tools/netcode.standards/netcode.standards.csproj diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..e29a8018 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,200 @@ +; see http://editorconfig.org/ for docs on this file + +root = true + +[*] +ignore_if_in_header = This code was generated by a tool| +indent_style = space +indent_size = 4 +; uncomment to help with sharing files across os's (i.e. network share or through local vm) +#end_of_line = lf +; avoid a bom, which causes endless problems with naive text tooling +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +; keeping auto-format enabled helps avoid merge hell for projects without CI-based format validation +#disable_auto_format = true + +[*.cs] +; uncomment to enable full formatting of c# files +formatters = generic, uncrustify + +[*.asmdef] +scrape_api = true + +[**/Tests/**.asmdef] +scrape_api = false + +[*.Tests.asmdef] +scrape_api = false + +[*.md] +indent_size = 2 +; trailing whitespace is unfortunately significant in markdown +trim_trailing_whitespace = false +; uncomment to enable basic formatting of markdown files +#formatters = generic + +[{Makefile,makefile}] +; tab characters are part of the Makefile format +indent_style = tab + +[*.asmdef] +indent_size = 4 + +[*.json] +indent_size = 2 + +[*.{vcproj,bat,cmd,xaml,tt,t4,ttinclude}] +end_of_line = crlf + +; this VS-specific stuff is based on experiments to see how VS will modify a file after it has been manually edited. +; the settings are meant to closely match what VS does to minimize unnecessary diffs. +[*.{vcxproj,vcxproj.filters}] +indent_style = space +indent_size = 2 +end_of_line = crlf +charset = utf-8-bom +trim_trailing_whitespace = true +insert_final_newline = false +; must be broken out because of 51-char bug (https://github.com/editorconfig/editorconfig-visualstudio/issues/21) +[*.{csproj,pyproj,props,targets}] +indent_style = space +indent_size = 2 +end_of_line = crlf +charset = utf-8-bom +trim_trailing_whitespace = true +insert_final_newline = false +[*.{sln,sln.template}] +indent_style = tab +indent_size = 4 +end_of_line = crlf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = false + +#### naming styles #### + +# naming rules +[*.cs] +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.method_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.method_should_be_pascal_case.symbols = method +dotnet_naming_rule.method_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.private_or_internal_field_should_be_begins_with_m_.severity = suggestion +dotnet_naming_rule.private_or_internal_field_should_be_begins_with_m_.symbols = private_or_internal_field +dotnet_naming_rule.private_or_internal_field_should_be_begins_with_m_.style = begins_with_m_ + +dotnet_naming_rule.private_or_internal_static_field_should_be_begins_with_s_.severity = suggestion +dotnet_naming_rule.private_or_internal_static_field_should_be_begins_with_s_.symbols = private_or_internal_static_field +dotnet_naming_rule.private_or_internal_static_field_should_be_begins_with_s_.style = begins_with_s_ + +dotnet_naming_rule.non_public_const_fields_should_be_begins_with_k_.severity = suggestion +dotnet_naming_rule.non_public_const_fields_should_be_begins_with_k_.symbols = non_public_const_fields +dotnet_naming_rule.non_public_const_fields_should_be_begins_with_k_.style = begins_with_k_ + +dotnet_naming_rule.non_public_static_readonly_fields_should_be_begins_with_k_.severity = suggestion +dotnet_naming_rule.non_public_static_readonly_fields_should_be_begins_with_k_.symbols = non_public_static_readonly_fields +dotnet_naming_rule.non_public_static_readonly_fields_should_be_begins_with_k_.style = begins_with_k_ + +dotnet_naming_rule.event_should_be_camel_case.severity = suggestion +dotnet_naming_rule.event_should_be_camel_case.symbols = event +dotnet_naming_rule.event_should_be_camel_case.style = camel_case + +dotnet_naming_rule.method_parameters_should_be_camel_case.severity = suggestion +dotnet_naming_rule.method_parameters_should_be_camel_case.symbols = method_parameters +dotnet_naming_rule.method_parameters_should_be_camel_case.style = camel_case + +dotnet_naming_rule.local_should_be_camel_case.severity = suggestion +dotnet_naming_rule.local_should_be_camel_case.symbols = local +dotnet_naming_rule.local_should_be_camel_case.style = camel_case + +# symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.event.applicable_kinds = event +dotnet_naming_symbols.event.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.event.required_modifiers = + +dotnet_naming_symbols.method.applicable_kinds = method +dotnet_naming_symbols.method.applicable_accessibilities = public +dotnet_naming_symbols.method.required_modifiers = + +dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field +dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected +dotnet_naming_symbols.private_or_internal_field.required_modifiers = + +dotnet_naming_symbols.private_or_internal_static_field.applicable_kinds = field +dotnet_naming_symbols.private_or_internal_static_field.applicable_accessibilities = internal, private, private_protected +dotnet_naming_symbols.private_or_internal_static_field.required_modifiers = static + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +dotnet_naming_symbols.non_public_const_fields.applicable_kinds = field +dotnet_naming_symbols.non_public_const_fields.applicable_accessibilities = internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_public_const_fields.required_modifiers = const + +dotnet_naming_symbols.non_public_static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.non_public_static_readonly_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_public_static_readonly_fields.required_modifiers = readonly, static + +dotnet_naming_symbols.method_parameters.applicable_kinds = parameter +dotnet_naming_symbols.method_parameters.applicable_accessibilities = +dotnet_naming_symbols.method_parameters.required_modifiers = + +dotnet_naming_symbols.local.applicable_kinds = local +dotnet_naming_symbols.local.applicable_accessibilities = local +dotnet_naming_symbols.local.required_modifiers = + +# naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +dotnet_naming_style.begins_with_m_.required_prefix = m_ +dotnet_naming_style.begins_with_m_.required_suffix = +dotnet_naming_style.begins_with_m_.word_separator = +dotnet_naming_style.begins_with_m_.capitalization = pascal_case + +dotnet_naming_style.begins_with_s_.required_prefix = s_ +dotnet_naming_style.begins_with_s_.required_suffix = +dotnet_naming_style.begins_with_s_.word_separator = +dotnet_naming_style.begins_with_s_.capitalization = pascal_case + +dotnet_naming_style.begins_with_k_.required_prefix = k_ +dotnet_naming_style.begins_with_k_.required_suffix = +dotnet_naming_style.begins_with_k_.word_separator = +dotnet_naming_style.begins_with_k_.capitalization = pascal_case + +dotnet_naming_style.camel_case.required_prefix = +dotnet_naming_style.camel_case.required_suffix = +dotnet_naming_style.camel_case.word_separator = +dotnet_naming_style.camel_case.capitalization = camel_case diff --git a/.yamato/build.yml b/.yamato/build.yml index 87af8f98..5082fca8 100644 --- a/.yamato/build.yml +++ b/.yamato/build.yml @@ -40,6 +40,7 @@ develop_pull_request_trigger: name: Develop Branch Triggers dependencies: {% for project in projects -%} + - .yamato/project-standards.yml#standards_{{ project.name }} {% for editor in test_editors -%} {% for platform in test_platforms -%} - .yamato/build.yml#build_{{ project.name }}_{{ editor }}_{{ platform.name }} diff --git a/.yamato/project-standards.yml b/.yamato/project-standards.yml new file mode 100644 index 00000000..e785f1c7 --- /dev/null +++ b/.yamato/project-standards.yml @@ -0,0 +1,22 @@ +{% metadata_file .yamato/project.metafile %} +--- + +{% for project in projects -%} +{% for editor in test_editors -%} + +standards_{{ project.name }}: + name: Standards Check {{ project.name }} - {{ editor }} + agent: + type: Unity::VM + image: desktop/logging-testing-linux:v0.1.2-926285 + flavor: b1.large + commands: + - dotnet --version + - dotnet format --version + - pip install unity-downloader-cli --upgrade --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple + - unity-downloader-cli -u {{ test_editors.first }} -c editor --wait --fast + - .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath {{ project.path }} -quit + - dotnet run --project dotnet-tools/netcode.standards -- --project={{ project.path }} --check + +{% endfor -%} +{% endfor -%} diff --git a/.yamato/project.metafile b/.yamato/project.metafile index 589d945e..77b7f0f4 100644 --- a/.yamato/project.metafile +++ b/.yamato/project.metafile @@ -32,4 +32,4 @@ projects: - name: dynamicaddressablesnetworkprefabs path: Basic/DynamicAddressablesNetworkPrefabs - name: multiplayerusecases - path: Experimental/MultiplayerUsecases \ No newline at end of file + path: Experimental/MultiplayerUseCases \ No newline at end of file diff --git a/Basic/2DSpaceShooter/Assets/Scripts/Asteroid.cs b/Basic/2DSpaceShooter/Assets/Scripts/Asteroid.cs index efcd1d33..b78a58c1 100644 --- a/Basic/2DSpaceShooter/Assets/Scripts/Asteroid.cs +++ b/Basic/2DSpaceShooter/Assets/Scripts/Asteroid.cs @@ -1,11 +1,11 @@ -using Unity.Netcode; +using Unity.Netcode; using UnityEngine; using UnityEngine.Assertions; public class Asteroid : NetworkBehaviour { static string s_ObjectPoolTag = "ObjectPool"; - + public static int numAsteroids = 0; NetworkObjectPool m_ObjectPool; @@ -14,7 +14,7 @@ public class Asteroid : NetworkBehaviour [SerializeField] private int m_NumCreates = 3; - + [HideInInspector] public GameObject asteroidPrefab; @@ -42,9 +42,9 @@ public void Explode() return; } Assert.IsTrue(NetworkManager.IsServer); - + numAsteroids -= 1; - + var newSize = Size.Value - 1; if (newSize > 0) @@ -56,9 +56,9 @@ public void Explode() int dx = Random.Range(0, 4) - 2; int dy = Random.Range(0, 4) - 2; Vector3 diff = new Vector3(dx * 0.3f, dy * 0.3f, 0); - + var go = m_ObjectPool.GetNetworkObject(asteroidPrefab, transform.position + diff, Quaternion.identity); - + var asteroid = go.GetComponent(); asteroid.Size = new NetworkVariable(newSize); asteroid.asteroidPrefab = asteroidPrefab; @@ -66,7 +66,7 @@ public void Explode() go.GetComponent().AddForce(diff * 10, ForceMode2D.Impulse); } } - + NetworkObject.Despawn(true); } } diff --git a/Basic/2DSpaceShooter/Assets/Scripts/Bullet.cs b/Basic/2DSpaceShooter/Assets/Scripts/Bullet.cs index ad398c6e..6ea5772c 100644 --- a/Basic/2DSpaceShooter/Assets/Scripts/Bullet.cs +++ b/Basic/2DSpaceShooter/Assets/Scripts/Bullet.cs @@ -1,4 +1,4 @@ -using System; +using System; using Unity.Netcode; using UnityEngine; diff --git a/Basic/2DSpaceShooter/Assets/Scripts/NetworkManagerHud.cs b/Basic/2DSpaceShooter/Assets/Scripts/NetworkManagerHud.cs index 30ed035f..9b56af39 100644 --- a/Basic/2DSpaceShooter/Assets/Scripts/NetworkManagerHud.cs +++ b/Basic/2DSpaceShooter/Assets/Scripts/NetworkManagerHud.cs @@ -14,35 +14,35 @@ public class NetworkManagerHud : MonoBehaviour NetworkManager m_NetworkManager; UnityTransport m_Transport; - + // This is needed to make the port field more convenient. GUILayout.TextField is very limited and we want to be able to clear the field entirely so we can't cache this as ushort. string m_PortString = "7777"; string m_ConnectAddress = "127.0.0.1"; - + [SerializeField] UIDocument m_MainMenuUIDocument; [SerializeField] UIDocument m_InGameUIDocument; - + VisualElement m_MainMenuRootVisualElement; VisualElement m_InGameRootVisualElement; - + Button m_HostButton; - + Button m_ServerButton; - + Button m_ClientButton; Button m_ShutdownButton; - + TextField m_IPAddressField; - + TextField m_PortField; TextElement m_MenuStatusText; - + TextElement m_InGameStatusText; void Awake() @@ -51,7 +51,7 @@ void Awake() m_NetworkManager = GetComponent(); m_MainMenuRootVisualElement = m_MainMenuUIDocument.rootVisualElement; - + m_IPAddressField = m_MainMenuRootVisualElement.Q("IPAddressField"); m_PortField = m_MainMenuRootVisualElement.Q("PortField"); m_HostButton = m_MainMenuRootVisualElement.Q