diff --git a/.editorconfig b/.editorconfig index 1609618e..a67dd408 100644 --- a/.editorconfig +++ b/.editorconfig @@ -21,6 +21,9 @@ end_of_line = lf [*.{cmd,bat}] end_of_line = crlf +[*.yml] +indent_size = 2 + [*.cs] #### .NET Coding Conventions #### @@ -143,7 +146,7 @@ csharp_indent_labels = one_less_than_current csharp_indent_switch_labels = true # Space preferences -csharp_space_after_cast = false +csharp_space_after_cast = true csharp_space_after_colon_in_inheritance_clause = true csharp_space_after_comma = true csharp_space_after_dot = false diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 00000000..a81dc3ce --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,37 @@ +name: CI-dotnet + +on: + pull_request: + paths: + - "**.cs" + - "**.csproj" + branches: [ master ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + inputs: + reason: + description: 'The reason for running the workflow' + required: true + default: 'Force run CI' + +jobs: + build: + runs-on: ubuntu-latest + name: Code analysis + steps: + - uses: actions/checkout@v2 + + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '3.1.x' + + - name: Dotnet format annotations + uses: xt0rted/dotnet-format-problem-matcher@v1 + + - name: Setup dotnet-format tool + run: dotnet tool install -g dotnet-format --version 5.0.\* + + - name: Run dotnet format + run: dotnet format --check diff --git a/code/gamemode/Game.Util.cs b/code/gamemode/Game.Util.cs index 9786679e..b4fe91e5 100644 --- a/code/gamemode/Game.Util.cs +++ b/code/gamemode/Game.Util.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; using Sandbox; +using System.Collections.Generic; using TTTReborn.Player; namespace TTTReborn.Gamemode diff --git a/code/gamemode/Game.cs b/code/gamemode/Game.cs index 0a609005..18e2d97f 100644 --- a/code/gamemode/Game.cs +++ b/code/gamemode/Game.cs @@ -1,9 +1,8 @@ -using System; using Sandbox; - -using TTTReborn.UI; +using System; using TTTReborn.Player; using TTTReborn.Rounds; +using TTTReborn.UI; namespace TTTReborn.Gamemode { @@ -105,7 +104,7 @@ private async void StartGameTimer() await GameTask.DelaySeconds(1); } - catch(Exception e) + catch (Exception e) { if (e.Message.Trim() == "A task was canceled.") { diff --git a/code/items/equipments/TTTEquipment.cs b/code/items/equipments/TTTEquipment.cs index e16a817a..cae931e1 100644 --- a/code/items/equipments/TTTEquipment.cs +++ b/code/items/equipments/TTTEquipment.cs @@ -1,6 +1,5 @@ -using System; using Sandbox; - +using System; using TTTReborn.Player; namespace TTTReborn.Items diff --git a/code/items/weapons/AmmoType.cs b/code/items/weapons/AmmoType.cs index d0418b92..a874ad0f 100644 --- a/code/items/weapons/AmmoType.cs +++ b/code/items/weapons/AmmoType.cs @@ -1,4 +1,4 @@ -namespace TTTReborn.Items +namespace TTTReborn.Items { public enum AmmoType { diff --git a/code/items/weapons/Knife.cs b/code/items/weapons/Knife.cs index a25ecec6..48d4f9ae 100644 --- a/code/items/weapons/Knife.cs +++ b/code/items/weapons/Knife.cs @@ -1,4 +1,4 @@ -using Sandbox; +using Sandbox; namespace TTTReborn.Items { diff --git a/code/items/weapons/Pistol.cs b/code/items/weapons/Pistol.cs index 82526e69..11006dca 100644 --- a/code/items/weapons/Pistol.cs +++ b/code/items/weapons/Pistol.cs @@ -1,4 +1,4 @@ -using Sandbox; +using Sandbox; namespace TTTReborn.Items { diff --git a/code/items/weapons/SMG.cs b/code/items/weapons/SMG.cs index f92c7adc..dbe90435 100644 --- a/code/items/weapons/SMG.cs +++ b/code/items/weapons/SMG.cs @@ -1,4 +1,4 @@ -using Sandbox; +using Sandbox; namespace TTTReborn.Items { diff --git a/code/items/weapons/Shotgun.cs b/code/items/weapons/Shotgun.cs index d15cb62f..3ab5aac0 100644 --- a/code/items/weapons/Shotgun.cs +++ b/code/items/weapons/Shotgun.cs @@ -1,4 +1,4 @@ -using Sandbox; +using Sandbox; using TTTReborn.Player; diff --git a/code/items/weapons/TTTWeapon.cs b/code/items/weapons/TTTWeapon.cs index fe64aff2..09f8106c 100644 --- a/code/items/weapons/TTTWeapon.cs +++ b/code/items/weapons/TTTWeapon.cs @@ -1,6 +1,5 @@ -using System; using Sandbox; - +using System; using TTTReborn.Player; using TTTReborn.UI; diff --git a/code/items/weapons/ViewModel.cs b/code/items/weapons/ViewModel.cs index 8e7f8e6b..c1ccd98f 100644 --- a/code/items/weapons/ViewModel.cs +++ b/code/items/weapons/ViewModel.cs @@ -1,4 +1,4 @@ -using Sandbox; +using Sandbox; using System; namespace TTTReborn.Items diff --git a/code/items/weapons/WeaponFunctions.cs b/code/items/weapons/WeaponFunctions.cs index 1b5ec6e7..e68b3146 100644 --- a/code/items/weapons/WeaponFunctions.cs +++ b/code/items/weapons/WeaponFunctions.cs @@ -1,9 +1,8 @@ +using Sandbox; using System; using System.Collections.Generic; using System.Linq; -using Sandbox; - namespace TTTReborn.Items { public static class WeaponFunctions diff --git a/code/player/Inventory.cs b/code/player/Inventory.cs index d1f25a16..ef338a11 100644 --- a/code/player/Inventory.cs +++ b/code/player/Inventory.cs @@ -1,7 +1,6 @@ -using System; -using System.Linq; using Sandbox; - +using System; +using System.Linq; using TTTReborn.Items; namespace TTTReborn.Player diff --git a/code/player/PlayerCorpse.cs b/code/player/PlayerCorpse.cs index 6c75c9c9..21b64059 100644 --- a/code/player/PlayerCorpse.cs +++ b/code/player/PlayerCorpse.cs @@ -1,55 +1,55 @@ -using Sandbox; +using Sandbox; namespace TTTReborn.Player { - public partial class PlayerCorpse : ModelEntity - { - public TTTPlayer Player { get; set; } + public partial class PlayerCorpse : ModelEntity + { + public TTTPlayer Player { get; set; } - [Net] - public bool IsIdentified { get; set; } = false; + [Net] + public bool IsIdentified { get; set; } = false; - public PlayerCorpse() - { - MoveType = MoveType.Physics; - UsePhysicsCollision = true; + public PlayerCorpse() + { + MoveType = MoveType.Physics; + UsePhysicsCollision = true; - SetInteractsAs(CollisionLayer.Debris); - SetInteractsWith(CollisionLayer.WORLD_GEOMETRY); - SetInteractsExclude(CollisionLayer.Player | CollisionLayer.Debris); + SetInteractsAs(CollisionLayer.Debris); + SetInteractsWith(CollisionLayer.WORLD_GEOMETRY); + SetInteractsExclude(CollisionLayer.Player | CollisionLayer.Debris); - IsIdentified = false; - } + IsIdentified = false; + } - public void CopyFrom(TTTPlayer player) - { - SetModel(player.GetModelName()); - TakeDecalsFrom(player); + public void CopyFrom(TTTPlayer player) + { + SetModel(player.GetModelName()); + TakeDecalsFrom(player); - this.CopyBonesFrom(player); - this.SetRagdollVelocityFrom(player); + this.CopyBonesFrom(player); + this.SetRagdollVelocityFrom(player); - foreach (Entity child in player.Children) - { - if (child is ModelEntity e) - { - string model = e.GetModelName(); + foreach (Entity child in player.Children) + { + if (child is ModelEntity e) + { + string model = e.GetModelName(); - if (model != null && !model.Contains("clothes")) - { - continue; - } + if (model != null && !model.Contains("clothes")) + { + continue; + } - ModelEntity clothing = new ModelEntity(); - clothing.SetModel(model); - clothing.SetParent(this, true); - } - } - } + ModelEntity clothing = new ModelEntity(); + clothing.SetModel(model); + clothing.SetParent(this, true); + } + } + } - public void ApplyForceToBone(Vector3 force, int forceBone) - { - PhysicsGroup.AddVelocity(force); + public void ApplyForceToBone(Vector3 force, int forceBone) + { + PhysicsGroup.AddVelocity(force); if (forceBone < 0) { @@ -67,5 +67,5 @@ public void ApplyForceToBone(Vector3 force, int forceBone) PhysicsGroup.AddVelocity(force); } } - } + } } diff --git a/code/player/TTTPlayer.Ammo.cs b/code/player/TTTPlayer.Ammo.cs index 215a48ca..0de9260f 100644 --- a/code/player/TTTPlayer.Ammo.cs +++ b/code/player/TTTPlayer.Ammo.cs @@ -1,4 +1,4 @@ -using Sandbox; +using Sandbox; using System; using System.Collections.Generic; @@ -18,7 +18,7 @@ public void ClearAmmo() public int AmmoCount(AmmoType type) { - int iType = (int)type; + int iType = (int) type; if (Ammo == null || Ammo.Count <= iType) { @@ -30,7 +30,7 @@ public int AmmoCount(AmmoType type) public bool SetAmmo(AmmoType type, int amount) { - int iType = (int)type; + int iType = (int) type; if (!Host.IsServer || Ammo == null) { diff --git a/code/player/TTTPlayer.Clothes.cs b/code/player/TTTPlayer.Clothes.cs index ccde483e..2f679211 100644 --- a/code/player/TTTPlayer.Clothes.cs +++ b/code/player/TTTPlayer.Clothes.cs @@ -1,4 +1,4 @@ -using Sandbox; +using Sandbox; using System.Collections.Generic; namespace TTTReborn.Player diff --git a/code/player/TTTPlayer.Commands.cs b/code/player/TTTPlayer.Commands.cs index 1f711344..e9fc4893 100644 --- a/code/player/TTTPlayer.Commands.cs +++ b/code/player/TTTPlayer.Commands.cs @@ -1,8 +1,7 @@ +using Sandbox; using System; -using System.Linq; using System.Collections.Generic; -using Sandbox; - +using System.Linq; using TTTReborn.Items; using TTTReborn.Roles; diff --git a/code/player/TTTPlayer.Confirmation.cs b/code/player/TTTPlayer.Confirmation.cs index 33ef57ae..27e55386 100644 --- a/code/player/TTTPlayer.Confirmation.cs +++ b/code/player/TTTPlayer.Confirmation.cs @@ -1,4 +1,4 @@ -using Sandbox; +using Sandbox; namespace TTTReborn.Player { diff --git a/code/player/TTTPlayer.FallDamage.cs b/code/player/TTTPlayer.FallDamage.cs index 7e9d6b98..30f00635 100644 --- a/code/player/TTTPlayer.FallDamage.cs +++ b/code/player/TTTPlayer.FallDamage.cs @@ -1,5 +1,5 @@ -using System; using Sandbox; +using System; namespace TTTReborn.Player { @@ -40,9 +40,9 @@ public void OnPlayerHitGround(float fallingHeight) { Attacker = this, Body = PhysicsBody, - Damage = (float)Math.Round(0.15f * (fallingHeight - FALLING_OBLIGINGNESS)), + Damage = (float) Math.Round(0.15f * (fallingHeight - FALLING_OBLIGINGNESS)), Flags = DamageFlags.Fall, - HitboxIndex = (int)HitboxIndex.LeftFoot, + HitboxIndex = (int) HitboxIndex.LeftFoot, Position = Position }; diff --git a/code/player/TTTPlayer.RPCs.cs b/code/player/TTTPlayer.RPCs.cs index 3786b977..14b263bf 100644 --- a/code/player/TTTPlayer.RPCs.cs +++ b/code/player/TTTPlayer.RPCs.cs @@ -1,8 +1,7 @@ using Sandbox; - using TTTReborn.Roles; -using TTTReborn.UI; using TTTReborn.Teams; +using TTTReborn.UI; namespace TTTReborn.Player { diff --git a/code/player/TTTPlayer.Roles.cs b/code/player/TTTPlayer.Roles.cs index d4346972..abe69474 100644 --- a/code/player/TTTPlayer.Roles.cs +++ b/code/player/TTTPlayer.Roles.cs @@ -1,11 +1,12 @@ -using TTTReborn.Roles; +using TTTReborn.Roles; using TTTReborn.Teams; namespace TTTReborn.Player { partial class TTTPlayer { - public TTTRole Role { + public TTTRole Role + { get { if (_role == null) diff --git a/code/player/TTTPlayer.Status.cs b/code/player/TTTPlayer.Status.cs index a3c58f63..07e23b5a 100644 --- a/code/player/TTTPlayer.Status.cs +++ b/code/player/TTTPlayer.Status.cs @@ -1,5 +1,5 @@ -using System; using Sandbox; +using System; namespace TTTReborn.Player { diff --git a/code/player/TTTPlayer.cs b/code/player/TTTPlayer.cs index 55472d7e..0b3b75a0 100644 --- a/code/player/TTTPlayer.cs +++ b/code/player/TTTPlayer.cs @@ -1,8 +1,7 @@ using Sandbox; - +using TTTReborn.Items; using TTTReborn.Player.Camera; using TTTReborn.Roles; -using TTTReborn.Items; namespace TTTReborn.Player { @@ -44,7 +43,7 @@ public void InitialRespawn() bool isPostRound = Gamemode.Game.Instance.Round is Rounds.PostRound; // sync roles - using(Prediction.Off()) + using (Prediction.Off()) { foreach (TTTPlayer player in Gamemode.Game.GetPlayers()) { @@ -78,7 +77,7 @@ public override void Respawn() GetClientOwner().SetScore("alive", true); - using(Prediction.Off()) + using (Prediction.Off()) { ClientOnPlayerSpawned(this); ClientSetRole(To.Single(this), Role.Name); @@ -115,7 +114,7 @@ public override void OnKilled() Inventory.DropActive(); Inventory.DeleteContents(); - using(Prediction.Off()) + using (Prediction.Off()) { ClientOnPlayerDied(To.Single(this), this); } diff --git a/code/player/camera/SpectateCamera.cs b/code/player/camera/SpectateCamera.cs index fd05da59..cccb0288 100644 --- a/code/player/camera/SpectateCamera.cs +++ b/code/player/camera/SpectateCamera.cs @@ -1,6 +1,6 @@ +using Sandbox; using System.Collections.Generic; using System.Linq; -using Sandbox; namespace TTTReborn.Player.Camera { diff --git a/code/roles/TTTRole.cs b/code/roles/TTTRole.cs index b827bc3f..56347277 100644 --- a/code/roles/TTTRole.cs +++ b/code/roles/TTTRole.cs @@ -1,8 +1,7 @@ +using Sandbox; using System; using System.Collections.Generic; using System.Linq; -using Sandbox; - using TTTReborn.Player; using TTTReborn.Teams; diff --git a/code/rounds/InProgressRound.cs b/code/rounds/InProgressRound.cs index 50637f90..1dfa530f 100644 --- a/code/rounds/InProgressRound.cs +++ b/code/rounds/InProgressRound.cs @@ -1,10 +1,9 @@ -using System; using Sandbox; +using System; using System.Collections.Generic; using System.Linq; - -using TTTReborn.Player; using TTTReborn.Items; +using TTTReborn.Player; using TTTReborn.Roles; using TTTReborn.Teams; @@ -155,7 +154,7 @@ private void AssignRoles() } // send everyone their roles - using(Prediction.Off()) + using (Prediction.Off()) { player.ClientSetRole(To.Single(player), player.Role.Name); } diff --git a/code/rounds/PostRound.cs b/code/rounds/PostRound.cs index faa36ff4..d53a3591 100644 --- a/code/rounds/PostRound.cs +++ b/code/rounds/PostRound.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - using Sandbox; +using System.Collections.Generic; using TTTReborn.Player; namespace TTTReborn.Rounds @@ -47,7 +46,7 @@ protected override void OnStart() { if (Host.IsServer) { - using(Prediction.Off()) + using (Prediction.Off()) { foreach (TTTPlayer player in TTTReborn.Gamemode.Game.GetPlayers()) { diff --git a/code/rounds/PreRound.cs b/code/rounds/PreRound.cs index c5d68931..fb5464fa 100644 --- a/code/rounds/PreRound.cs +++ b/code/rounds/PreRound.cs @@ -1,8 +1,7 @@ using Sandbox; using System.Threading.Tasks; - -using TTTReborn.Player; using TTTReborn.Items; +using TTTReborn.Player; namespace TTTReborn.Rounds { @@ -22,7 +21,7 @@ protected override void OnStart() { if (Host.IsServer) { - foreach(Entity entity in Entity.All) + foreach (Entity entity in Entity.All) { if (entity is TTTWeapon weapon) { diff --git a/code/ui/Crosshair.cs b/code/ui/Crosshair.cs index 474e3a85..857025ac 100644 --- a/code/ui/Crosshair.cs +++ b/code/ui/Crosshair.cs @@ -1,8 +1,7 @@ -using Sandbox; +using Sandbox; using Sandbox.UI; - -using TTTReborn.Player; using TTTReborn.Items; +using TTTReborn.Player; namespace TTTReborn.UI { diff --git a/code/ui/InfoFeedEntry.cs b/code/ui/InfoFeedEntry.cs index e951b5ff..ca6cb846 100644 --- a/code/ui/InfoFeedEntry.cs +++ b/code/ui/InfoFeedEntry.cs @@ -1,21 +1,20 @@ -using System.Collections.Generic; - using Sandbox; using Sandbox.UI; using Sandbox.UI.Construct; +using System.Collections.Generic; namespace TTTReborn.UI { - public partial class InfoFeedEntry : Panel - { + public partial class InfoFeedEntry : Panel + { private readonly List