From a8af7db85f35eec12148b0b558b01f14e007af2f Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Mon, 4 Mar 2024 15:48:22 -0500 Subject: [PATCH 01/27] standards job added per sample project --- .yamato/build.yml | 1 + .yamato/project-standards.yml | 22 ++ dotnet-tools/.gitignore | 454 ++++++++++++++++++++++ dotnet-tools/README.md | 61 +++ dotnet-tools/netcode.standards/Program.cs | 66 ++++ 5 files changed, 604 insertions(+) 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 diff --git a/.yamato/build.yml b/.yamato/build.yml index 87af8f986..ad0cc26e0 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 000000000..bcfcd1609 --- /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 + 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/dotnet-tools/.gitignore b/dotnet-tools/.gitignore new file mode 100644 index 000000000..8afdcb635 --- /dev/null +++ b/dotnet-tools/.gitignore @@ -0,0 +1,454 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# JetBrains Rider +.idea/ +*.sln.iml + +## +## Visual Studio Code +## +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json diff --git a/dotnet-tools/README.md b/dotnet-tools/README.md new file mode 100644 index 000000000..9fe158433 --- /dev/null +++ b/dotnet-tools/README.md @@ -0,0 +1,61 @@ +# .NET Tools for Unity Netcode + +## Netcode.Standards + +C# coding standards tool for Netcode that relies on `.editorconfig` ruleset and `dotnet format` tool + +### How to Install & Uninstall + +Build (Pack) + +```zsh +dotnet pack dotnet-tools/netcode.standards +``` + +Install + +```zsh +dotnet tool install --global --add-source ./dotnet-tools/netcode.standards netcode.standards +``` + +Check + +```zsh +netcode.standards --help +``` + +Uninstall + +```zsh +dotnet tool uninstall --global netcode.standards +``` + +### How to Use + +#### Commands + +Check + +```zsh +# check for standards issues without touching files +netcode.standards --check +``` + +Fix +```zsh +# try to fix standards issues and save file changes +netcode.standards --fix +``` + +#### Options + +Specifying at least one of `--check` or `--fix` is required. + +However, you can also specify other options to configure the tool. + +|Option|Description| +|:-|:-| +|`--project `|Target project folder [default: testproject]| +|`--pattern `|Search pattern string [default: *.sln]| +|`--verbosity `|Logs verbosity level [default: normal]| +|`-?`, `-h`, `--help`|Show help and usage information| diff --git a/dotnet-tools/netcode.standards/Program.cs b/dotnet-tools/netcode.standards/Program.cs new file mode 100644 index 000000000..2a8ce865a --- /dev/null +++ b/dotnet-tools/netcode.standards/Program.cs @@ -0,0 +1,66 @@ +using System; +using System.IO; +using System.Diagnostics; + +internal static class Program +{ + /// + /// C# coding standards tool for Netcode that relies on `.editorconfig` ruleset and `dotnet format` tool + /// + /// Check for standards issues (will not change files) + /// Try to fix standards issues (could change files) + /// Target project folder + /// Search pattern string + /// Logs verbosity level + private static int Main( + bool check = false, bool fix = false, + string project = "", + string pattern = "*.sln", + string verbosity = "normal") + { + if (check && fix) + { + Console.WriteLine($"FAILED: Please use --{nameof(check)} or --{nameof(fix)} individually, not both at the same time"); + return 1; + } + + if (!check && !fix) + { + Console.WriteLine($"FAILED: Please use at least one of --{nameof(check)} or --{nameof(fix)} workflows"); + return 2; + } + + foreach (var file in Directory.GetFiles(project, pattern)) + { + var procInfo = new ProcessStartInfo("dotnet"); + + procInfo.Arguments = check + ? $"format {file} whitespace --no-restore --verify-no-changes --verbosity {verbosity}" + : $"format {file} whitespace --no-restore --verbosity {verbosity}"; + Console.WriteLine($"######## START -> {(check ? "check" : "fix")} whitespace issues"); + var whitespace = Process.Start(procInfo); + whitespace.WaitForExit(); + if (whitespace.ExitCode != 0) + { + Console.WriteLine("######## FAILED -> found whitespace issues (see details above)"); + return whitespace.ExitCode; + } + Console.WriteLine("######## SUCCEEDED -> no whitespace issues"); + + procInfo.Arguments = check + ? $"format {file} style --severity error --no-restore --verify-no-changes --verbosity {verbosity}" + : $"format {file} style --severity error --no-restore --verbosity {verbosity}"; + Console.WriteLine($"######## START -> {(check ? "check" : "fix")} style/naming issues"); + var style = Process.Start(procInfo); + style.WaitForExit(); + if (style.ExitCode != 0) + { + Console.WriteLine("######## FAILED -> found style/naming issues (see details above)"); + return style.ExitCode; + } + Console.WriteLine("######## SUCCEEDED -> no style/naming issues"); + } + + return 0; + } +} From 8bfff55b4e095baa9754478eb81cf4e0dfa5bdd7 Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Mon, 4 Mar 2024 15:56:58 -0500 Subject: [PATCH 02/27] indentation --- .yamato/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.yamato/build.yml b/.yamato/build.yml index ad0cc26e0..5082fca88 100644 --- a/.yamato/build.yml +++ b/.yamato/build.yml @@ -40,7 +40,7 @@ develop_pull_request_trigger: name: Develop Branch Triggers dependencies: {% for project in projects -%} -- .yamato/project-standards.yml#standards_{{ project.name }} + - .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 }} From 90fc5cfef25b1c28d3ffe6e2058da9571ef326ad Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Mon, 4 Mar 2024 16:03:34 -0500 Subject: [PATCH 03/27] descriptive job name per project --- .yamato/project-standards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.yamato/project-standards.yml b/.yamato/project-standards.yml index bcfcd1609..e785f1c70 100644 --- a/.yamato/project-standards.yml +++ b/.yamato/project-standards.yml @@ -5,7 +5,7 @@ {% for editor in test_editors -%} standards_{{ project.name }}: - name: Standards Check + name: Standards Check {{ project.name }} - {{ editor }} agent: type: Unity::VM image: desktop/logging-testing-linux:v0.1.2-926285 From ff8d13556e582dd087dfb384fcfa656de35d3ddf Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Mon, 4 Mar 2024 16:26:12 -0500 Subject: [PATCH 04/27] relative path to projects --- .yamato/project.metafile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.yamato/project.metafile b/.yamato/project.metafile index 589d945e4..39d266b58 100644 --- a/.yamato/project.metafile +++ b/.yamato/project.metafile @@ -24,12 +24,12 @@ test_platforms: # for job ids, so it should not contain spaces/non-supported characters projects: - name: 2dspaceshooter - path: Basic/2DSpaceShooter + path: ./Basic/2DSpaceShooter - name: invaders - path: Basic/Invaders + path: ./Basic/Invaders - name: clientdriven - path: Basic/ClientDriven + path: ./Basic/ClientDriven - name: dynamicaddressablesnetworkprefabs - path: Basic/DynamicAddressablesNetworkPrefabs + path: ./Basic/DynamicAddressablesNetworkPrefabs - name: multiplayerusecases - path: Experimental/MultiplayerUsecases \ No newline at end of file + path: ./Experimental/MultiplayerUsecases \ No newline at end of file From b3d3ca9b5b277d31e9cd2a1b15e620e5cef06a71 Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Tue, 5 Mar 2024 13:33:24 -0500 Subject: [PATCH 05/27] path backslash change --- .yamato/project.metafile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.yamato/project.metafile b/.yamato/project.metafile index 39d266b58..636195beb 100644 --- a/.yamato/project.metafile +++ b/.yamato/project.metafile @@ -24,12 +24,12 @@ test_platforms: # for job ids, so it should not contain spaces/non-supported characters projects: - name: 2dspaceshooter - path: ./Basic/2DSpaceShooter + path: .\Basic\2DSpaceShooter - name: invaders - path: ./Basic/Invaders + path: .\Basic\Invaders - name: clientdriven - path: ./Basic/ClientDriven + path: .\Basic\ClientDriven - name: dynamicaddressablesnetworkprefabs - path: ./Basic/DynamicAddressablesNetworkPrefabs + path: .\Basic\DynamicAddressablesNetworkPrefabs - name: multiplayerusecases - path: ./Experimental/MultiplayerUsecases \ No newline at end of file + path: .\Experimental\MultiplayerUseCases \ No newline at end of file From ffe2cd461b162570a3631240c3fb96a9dea4e716 Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Tue, 5 Mar 2024 14:03:26 -0500 Subject: [PATCH 06/27] path changes --- .yamato/project.metafile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.yamato/project.metafile b/.yamato/project.metafile index 636195beb..350c801e0 100644 --- a/.yamato/project.metafile +++ b/.yamato/project.metafile @@ -24,12 +24,12 @@ test_platforms: # for job ids, so it should not contain spaces/non-supported characters projects: - name: 2dspaceshooter - path: .\Basic\2DSpaceShooter + path: /Basic/2DSpaceShooter - name: invaders - path: .\Basic\Invaders + path: /Basic/Invaders - name: clientdriven - path: .\Basic\ClientDriven + path: /Basic/ClientDriven - name: dynamicaddressablesnetworkprefabs - path: .\Basic\DynamicAddressablesNetworkPrefabs + path: /Basic/DynamicAddressablesNetworkPrefabs - name: multiplayerusecases - path: .\Experimental\MultiplayerUseCases \ No newline at end of file + path: /Experimental/MultiplayerUseCases \ No newline at end of file From a09bd3ff0d55d03e59c33a79dfa0cebebb5271b0 Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Tue, 5 Mar 2024 16:24:42 -0500 Subject: [PATCH 07/27] test client driven job --- .yamato/project-standards.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.yamato/project-standards.yml b/.yamato/project-standards.yml index e785f1c70..5b9f9e3c6 100644 --- a/.yamato/project-standards.yml +++ b/.yamato/project-standards.yml @@ -20,3 +20,18 @@ standards_{{ project.name }}: {% endfor -%} {% endfor -%} + + +standards_client-driven: + name: Standards Check Client Driven + 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 2022.3 -c editor --wait --fast + - .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath /Basic/ClientDriven -quit + - dotnet run --project dotnet-tools/netcode.standards -- --project=/Basic/ClientDriven --check \ No newline at end of file From e3b8e9510c470264f3ad146ec5e149846b070cca Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Tue, 5 Mar 2024 16:55:21 -0500 Subject: [PATCH 08/27] path format --- .yamato/project-standards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.yamato/project-standards.yml b/.yamato/project-standards.yml index 5b9f9e3c6..3397c02fb 100644 --- a/.yamato/project-standards.yml +++ b/.yamato/project-standards.yml @@ -34,4 +34,4 @@ standards_client-driven: - pip install unity-downloader-cli --upgrade --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple - unity-downloader-cli -u 2022.3 -c editor --wait --fast - .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath /Basic/ClientDriven -quit - - dotnet run --project dotnet-tools/netcode.standards -- --project=/Basic/ClientDriven --check \ No newline at end of file + - dotnet run --project dotnet-tools/netcode.standards -- --project ./Basic/ClientDriven --check \ No newline at end of file From d7088ad6137686508503e89cd549c99081c3a54d Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Tue, 5 Mar 2024 17:20:33 -0500 Subject: [PATCH 09/27] trailing folder --- .yamato/project-standards.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.yamato/project-standards.yml b/.yamato/project-standards.yml index 3397c02fb..eb0456f62 100644 --- a/.yamato/project-standards.yml +++ b/.yamato/project-standards.yml @@ -33,5 +33,5 @@ standards_client-driven: - 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 2022.3 -c editor --wait --fast - - .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath /Basic/ClientDriven -quit - - dotnet run --project dotnet-tools/netcode.standards -- --project ./Basic/ClientDriven --check \ No newline at end of file + - .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath ./Basic/ClientDriven/ -quit + - dotnet run --project dotnet-tools/netcode.standards -- --project ./Basic/ClientDriven/ --check \ No newline at end of file From 0d2dab49c7b3904bfa2f714d76f724237c1a3b2d Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Tue, 5 Mar 2024 17:39:44 -0500 Subject: [PATCH 10/27] current path? --- .yamato/project-standards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.yamato/project-standards.yml b/.yamato/project-standards.yml index eb0456f62..c4e9971e9 100644 --- a/.yamato/project-standards.yml +++ b/.yamato/project-standards.yml @@ -34,4 +34,4 @@ standards_client-driven: - pip install unity-downloader-cli --upgrade --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple - unity-downloader-cli -u 2022.3 -c editor --wait --fast - .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath ./Basic/ClientDriven/ -quit - - dotnet run --project dotnet-tools/netcode.standards -- --project ./Basic/ClientDriven/ --check \ No newline at end of file + - dotnet run --project dotnet-tools/netcode.standards -- --project . --check \ No newline at end of file From 06c9e97ca0c76a173e8a7a2ff502ecc7a5de07e3 Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Tue, 5 Mar 2024 22:31:48 -0500 Subject: [PATCH 11/27] path change --- .yamato/project-standards.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.yamato/project-standards.yml b/.yamato/project-standards.yml index c4e9971e9..233824d34 100644 --- a/.yamato/project-standards.yml +++ b/.yamato/project-standards.yml @@ -33,5 +33,5 @@ standards_client-driven: - 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 2022.3 -c editor --wait --fast - - .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath ./Basic/ClientDriven/ -quit - - dotnet run --project dotnet-tools/netcode.standards -- --project . --check \ No newline at end of file + - .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath Basic/ClientDriven -quit + - dotnet run --project dotnet-tools/netcode.standards -- --project Basic/ClientDriven --check \ No newline at end of file From d3bbdb1a1f31b802d2367854410ff4c0a75395c5 Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Tue, 5 Mar 2024 22:45:11 -0500 Subject: [PATCH 12/27] path change --- .yamato/project-standards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.yamato/project-standards.yml b/.yamato/project-standards.yml index 233824d34..12e4c3800 100644 --- a/.yamato/project-standards.yml +++ b/.yamato/project-standards.yml @@ -34,4 +34,4 @@ standards_client-driven: - pip install unity-downloader-cli --upgrade --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple - unity-downloader-cli -u 2022.3 -c editor --wait --fast - .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath Basic/ClientDriven -quit - - dotnet run --project dotnet-tools/netcode.standards -- --project Basic/ClientDriven --check \ No newline at end of file + - dotnet run --project dotnet-tools/netcode.standards -- --project=Basic/ClientDriven --check \ No newline at end of file From ce7437fa45743cdfc44ed39d4a6ab0a8d942a029 Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Tue, 5 Mar 2024 22:54:41 -0500 Subject: [PATCH 13/27] lowercase? --- .yamato/project-standards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.yamato/project-standards.yml b/.yamato/project-standards.yml index 12e4c3800..15c23f9c0 100644 --- a/.yamato/project-standards.yml +++ b/.yamato/project-standards.yml @@ -34,4 +34,4 @@ standards_client-driven: - pip install unity-downloader-cli --upgrade --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple - unity-downloader-cli -u 2022.3 -c editor --wait --fast - .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath Basic/ClientDriven -quit - - dotnet run --project dotnet-tools/netcode.standards -- --project=Basic/ClientDriven --check \ No newline at end of file + - dotnet run --project dotnet-tools/netcode.standards -- --project=basic/clientdriven --check \ No newline at end of file From ad9f21caa24c32cf0af4a72c252158494bab8944 Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Tue, 5 Mar 2024 23:20:41 -0500 Subject: [PATCH 14/27] editorconfig added --- .editorconfig | 1 + 1 file changed, 1 insertion(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..85f678885 --- /dev/null +++ b/.editorconfig @@ -0,0 +1 @@ +; 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 csharp_indent_case_contents_when_block = false [*.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 \ No newline at end of file From d5bf14060aa7c22864a84ec98a346a7938821a5c Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Tue, 5 Mar 2024 23:35:11 -0500 Subject: [PATCH 15/27] actual netcode standards csproj file --- .../netcode.standards/netcode.standards.csproj | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 dotnet-tools/netcode.standards/netcode.standards.csproj diff --git a/dotnet-tools/netcode.standards/netcode.standards.csproj b/dotnet-tools/netcode.standards/netcode.standards.csproj new file mode 100644 index 000000000..74e37a217 --- /dev/null +++ b/dotnet-tools/netcode.standards/netcode.standards.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + true + netcode.standards + ./nupkg + + + + + + + \ No newline at end of file From b344572edcc645c36cad668f3121db26eeb01be3 Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Tue, 5 Mar 2024 23:45:10 -0500 Subject: [PATCH 16/27] actual path --- .yamato/project-standards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.yamato/project-standards.yml b/.yamato/project-standards.yml index 15c23f9c0..12e4c3800 100644 --- a/.yamato/project-standards.yml +++ b/.yamato/project-standards.yml @@ -34,4 +34,4 @@ standards_client-driven: - pip install unity-downloader-cli --upgrade --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple - unity-downloader-cli -u 2022.3 -c editor --wait --fast - .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath Basic/ClientDriven -quit - - dotnet run --project dotnet-tools/netcode.standards -- --project=basic/clientdriven --check \ No newline at end of file + - dotnet run --project dotnet-tools/netcode.standards -- --project=Basic/ClientDriven --check \ No newline at end of file From 8509bc10fd888da02a151f3f3b8704f1fa73aa33 Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Wed, 6 Mar 2024 12:43:13 -0500 Subject: [PATCH 17/27] removing test job, paths sorted --- .yamato/project-standards.yml | 15 --------------- .yamato/project.metafile | 10 +++++----- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/.yamato/project-standards.yml b/.yamato/project-standards.yml index 12e4c3800..e785f1c70 100644 --- a/.yamato/project-standards.yml +++ b/.yamato/project-standards.yml @@ -20,18 +20,3 @@ standards_{{ project.name }}: {% endfor -%} {% endfor -%} - - -standards_client-driven: - name: Standards Check Client Driven - 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 2022.3 -c editor --wait --fast - - .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath Basic/ClientDriven -quit - - dotnet run --project dotnet-tools/netcode.standards -- --project=Basic/ClientDriven --check \ No newline at end of file diff --git a/.yamato/project.metafile b/.yamato/project.metafile index 350c801e0..77b7f0f43 100644 --- a/.yamato/project.metafile +++ b/.yamato/project.metafile @@ -24,12 +24,12 @@ test_platforms: # for job ids, so it should not contain spaces/non-supported characters projects: - name: 2dspaceshooter - path: /Basic/2DSpaceShooter + path: Basic/2DSpaceShooter - name: invaders - path: /Basic/Invaders + path: Basic/Invaders - name: clientdriven - path: /Basic/ClientDriven + path: Basic/ClientDriven - name: dynamicaddressablesnetworkprefabs - path: /Basic/DynamicAddressablesNetworkPrefabs + path: Basic/DynamicAddressablesNetworkPrefabs - name: multiplayerusecases - path: /Experimental/MultiplayerUseCases \ No newline at end of file + path: Experimental/MultiplayerUseCases \ No newline at end of file From 9caed207f10abf8d3f425d6c0ec6f66e1efdebe9 Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Wed, 6 Mar 2024 12:49:40 -0500 Subject: [PATCH 18/27] Invaders formatted --- Basic/Invaders/Assets/Scripts/EnemyAgent.cs | 4 ++-- Basic/Invaders/Assets/Scripts/EnemyBullet.cs | 2 +- Basic/Invaders/Assets/Scripts/InvadersGame.cs | 22 +++++++++---------- 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 | 4 ++-- .../Assets/Scripts/SceneTransitionHandler.cs | 16 +++++++------- Basic/Invaders/Assets/Scripts/Shield.cs | 2 +- .../Assets/Scripts/SuperEnemyMovement.cs | 4 ++-- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Basic/Invaders/Assets/Scripts/EnemyAgent.cs b/Basic/Invaders/Assets/Scripts/EnemyAgent.cs index 6f5d7d10f..2cb398f5b 100644 --- a/Basic/Invaders/Assets/Scripts/EnemyAgent.cs +++ b/Basic/Invaders/Assets/Scripts/EnemyAgent.cs @@ -1,4 +1,4 @@ -using System; +using System; using Unity.Netcode; using UnityEngine; using UnityEngine.Assertions; @@ -61,7 +61,7 @@ private void Update() // Wait for the grace shooting period to pass return; } - + bool bCanShootThisFrame = false; if (IsServer && canShoot) if (Random.Range(0, 1.0f) > k_ShootingRandomThreshold) diff --git a/Basic/Invaders/Assets/Scripts/EnemyBullet.cs b/Basic/Invaders/Assets/Scripts/EnemyBullet.cs index 61059e3e8..672698022 100644 --- a/Basic/Invaders/Assets/Scripts/EnemyBullet.cs +++ b/Basic/Invaders/Assets/Scripts/EnemyBullet.cs @@ -1,4 +1,4 @@ -using System; +using System; using Unity.Netcode; using UnityEngine; using UnityEngine.Assertions; diff --git a/Basic/Invaders/Assets/Scripts/InvadersGame.cs b/Basic/Invaders/Assets/Scripts/InvadersGame.cs index 1bf2ab235..166d7acb5 100644 --- a/Basic/Invaders/Assets/Scripts/InvadersGame.cs +++ b/Basic/Invaders/Assets/Scripts/InvadersGame.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using TMPro; using Unity.Netcode; @@ -100,7 +100,7 @@ private void Awake() { Assert.IsNull(Singleton, $"Multiple instances of {nameof(InvadersGame)} detected. This should not happen."); Singleton = this; - + OnSingletonReady?.Invoke(); if (IsServer) @@ -198,7 +198,7 @@ private void OnClientConnected(ulong clientId) if (m_ReplicatedTimeSent) { // Send the RPC only to the newly connected client - SetReplicatedTimeRemainingClientRPC(m_TimeRemaining, new ClientRpcParams {Send = new ClientRpcSendParams{TargetClientIds = new List() {clientId}}}); + SetReplicatedTimeRemainingClientRPC(m_TimeRemaining, new ClientRpcParams { Send = new ClientRpcSendParams { TargetClientIds = new List() { clientId } } }); } } @@ -320,13 +320,13 @@ private void UpdateEnemies() UpdateEnemiesResultFlags enemiesResultFlags = UpdateEnemiesResultFlags.None; UpdateShootingEnemies(ref enemiesResultFlags); - if((enemiesResultFlags & UpdateEnemiesResultFlags.ReachedBottom) != 0) + if ((enemiesResultFlags & UpdateEnemiesResultFlags.ReachedBottom) != 0) { // Force game end as at least one of the enemies have reached the bottom! SetGameEnd(GameOverReason.EnemiesReachedBottom); return; } - + // If we didn't find any enemies, then spawn some if ((enemiesResultFlags & UpdateEnemiesResultFlags.FoundEnemy) == 0) { @@ -367,14 +367,14 @@ private void UpdateShootingEnemies(ref UpdateEnemiesResultFlags flags) { continue; } - + // If at least one of the enemies reached bottom, return early. if (enemy.transform.position.y <= k_BottomBoundaryOffset) { flags |= UpdateEnemiesResultFlags.ReachedBottom; return; } - + if (enemy.score > 100) continue; @@ -435,17 +435,17 @@ public void SetGameEnd(GameOverReason reason) BroadcastGameOverClientRpc(reason); // Notify our clients! return; } - + foreach (NetworkClient networkedClient in NetworkManager.Singleton.ConnectedClientsList) { var playerObject = networkedClient.PlayerObject; - if(playerObject == null) continue; - + if (playerObject == null) continue; + // We should just early out if any of the player's are still alive if (playerObject.GetComponent().IsAlive) return; } - + this.isGameOver.Value = true; } diff --git a/Basic/Invaders/Assets/Scripts/LobbyControl.cs b/Basic/Invaders/Assets/Scripts/LobbyControl.cs index dd4ad8d8a..ebcfae2c9 100644 --- a/Basic/Invaders/Assets/Scripts/LobbyControl.cs +++ b/Basic/Invaders/Assets/Scripts/LobbyControl.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using TMPro; using Unity.Netcode; @@ -9,11 +9,11 @@ public class LobbyControl : NetworkBehaviour { [SerializeField] private string m_InGameSceneName = "InGame"; - + // Minimum player count required to transition to next level [SerializeField] private int m_MinimumPlayerCount = 2; - + public TMP_Text LobbyText; private bool m_AllPlayersInLobby; @@ -23,7 +23,7 @@ public class LobbyControl : NetworkBehaviour public override void OnNetworkSpawn() { m_ClientsInLobby = new Dictionary(); - + //Always add ourselves to the list at first m_ClientsInLobby.Add(NetworkManager.LocalClientId, false); diff --git a/Basic/Invaders/Assets/Scripts/MenuControl.cs b/Basic/Invaders/Assets/Scripts/MenuControl.cs index a6365363b..d8fe541e4 100644 --- a/Basic/Invaders/Assets/Scripts/MenuControl.cs +++ b/Basic/Invaders/Assets/Scripts/MenuControl.cs @@ -42,7 +42,7 @@ public void JoinGame() Debug.LogError("Failed to start client."); } } - + static string Sanitize(string dirtyString) { // sanitize the input for the ip address diff --git a/Basic/Invaders/Assets/Scripts/PlayerBullet.cs b/Basic/Invaders/Assets/Scripts/PlayerBullet.cs index 021559c4e..511fd833d 100644 --- a/Basic/Invaders/Assets/Scripts/PlayerBullet.cs +++ b/Basic/Invaders/Assets/Scripts/PlayerBullet.cs @@ -1,4 +1,4 @@ -using System; +using System; using Unity.Netcode; using UnityEngine; @@ -49,11 +49,11 @@ private void OnTriggerEnter2D(Collider2D collider) // Only the server can despawn a NetworkObject hitEnemy.NetworkObject.Despawn(); - + SpawnExplosionVFXClientRPC(transform.position, Quaternion.identity); - + NetworkObject.Despawn(); - + return; } diff --git a/Basic/Invaders/Assets/Scripts/PlayerControl.cs b/Basic/Invaders/Assets/Scripts/PlayerControl.cs index 0ddd14459..659b2ab17 100644 --- a/Basic/Invaders/Assets/Scripts/PlayerControl.cs +++ b/Basic/Invaders/Assets/Scripts/PlayerControl.cs @@ -1,4 +1,4 @@ -using System; +using System; using Unity.Mathematics; using Unity.Netcode; using UnityEngine; @@ -120,7 +120,7 @@ public override void OnNetworkSpawn() InvadersGame.OnSingletonReady += SubscribeToDelegatesAndUpdateValues; else SubscribeToDelegatesAndUpdateValues(); - + SceneTransitionHandler.sceneTransitionHandler.OnSceneStateChanged += SceneTransitionHandler_sceneStateChanged; UpdateColor(); } diff --git a/Basic/Invaders/Assets/Scripts/SceneTransitionHandler.cs b/Basic/Invaders/Assets/Scripts/SceneTransitionHandler.cs index 79515437a..57334a489 100644 --- a/Basic/Invaders/Assets/Scripts/SceneTransitionHandler.cs +++ b/Basic/Invaders/Assets/Scripts/SceneTransitionHandler.cs @@ -21,7 +21,7 @@ public class SceneTransitionHandler : NetworkBehaviour public event SceneStateChangedDelegateHandler OnSceneStateChanged; private int m_numberOfClientLoaded; - + /// /// Example scene states /// @@ -42,7 +42,7 @@ public enum SceneStates /// private void Awake() { - if(sceneTransitionHandler != this && sceneTransitionHandler != null) + if (sceneTransitionHandler != this && sceneTransitionHandler != null) { GameObject.Destroy(sceneTransitionHandler.gameObject); } @@ -59,7 +59,7 @@ private void Awake() public void SetSceneState(SceneStates sceneState) { m_SceneState = sceneState; - if(OnSceneStateChanged != null) + if (OnSceneStateChanged != null) { OnSceneStateChanged.Invoke(m_SceneState); } @@ -81,7 +81,7 @@ public SceneStates GetCurrentSceneState() /// private void Start() { - if(m_SceneState == SceneStates.Init) + if (m_SceneState == SceneStates.Init) { SceneManager.LoadScene(DefaultMainMenu); } @@ -93,7 +93,7 @@ private void Start() public void RegisterCallbacks() { NetworkManager.Singleton.SceneManager.OnLoadComplete += OnLoadComplete; - + } /// @@ -102,7 +102,7 @@ public void RegisterCallbacks() /// public void SwitchScene(string scenename) { - if(NetworkManager.Singleton.IsListening) + if (NetworkManager.Singleton.IsListening) { m_numberOfClientLoaded = 0; NetworkManager.Singleton.SceneManager.LoadScene(scenename, LoadSceneMode.Single); @@ -134,9 +134,9 @@ public void ExitAndLoadStartMenu() { NetworkManager.Singleton.SceneManager.OnLoadComplete -= OnLoadComplete; } - + OnClientLoadedScene = null; SetSceneState(SceneStates.Start); SceneManager.LoadScene(1); } -} \ No newline at end of file +} diff --git a/Basic/Invaders/Assets/Scripts/Shield.cs b/Basic/Invaders/Assets/Scripts/Shield.cs index 17b6a02be..7dc32c7b4 100644 --- a/Basic/Invaders/Assets/Scripts/Shield.cs +++ b/Basic/Invaders/Assets/Scripts/Shield.cs @@ -1,4 +1,4 @@ -using Unity.Mathematics; +using Unity.Mathematics; using Unity.Netcode; using UnityEngine; diff --git a/Basic/Invaders/Assets/Scripts/SuperEnemyMovement.cs b/Basic/Invaders/Assets/Scripts/SuperEnemyMovement.cs index 0bec46745..cc6f97504 100644 --- a/Basic/Invaders/Assets/Scripts/SuperEnemyMovement.cs +++ b/Basic/Invaders/Assets/Scripts/SuperEnemyMovement.cs @@ -1,4 +1,4 @@ -using Unity.Netcode; +using Unity.Netcode; using UnityEngine; public class SuperEnemyMovement : NetworkBehaviour @@ -14,7 +14,7 @@ public class SuperEnemyMovement : NetworkBehaviour private void Update() { if (!IsServer) return; - + if (transform.position.x > k_YBoundary) { if (IsServer) NetworkObject.Despawn(); From 59352dff0aa5867529a6f268b6ff01d2694ca3a3 Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Wed, 6 Mar 2024 12:53:05 -0500 Subject: [PATCH 19/27] 2DSpaceShooter formatted --- .../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 ++--- 7 files changed, 117 insertions(+), 117 deletions(-) diff --git a/Basic/2DSpaceShooter/Assets/Scripts/Asteroid.cs b/Basic/2DSpaceShooter/Assets/Scripts/Asteroid.cs index efcd1d334..b78a58c11 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 ad398c6ed..6ea5772cb 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 30ed035fe..9b56af396 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