From 9eac49e91e38276aa8d06b37a9434a428ec37bdf Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 14 Jan 2024 18:11:08 +0530 Subject: [PATCH 1/6] Trying to update break-manager. --- cs2-retakes.sln | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 cs2-retakes.sln diff --git a/cs2-retakes.sln b/cs2-retakes.sln new file mode 100644 index 0000000..4fb87ba --- /dev/null +++ b/cs2-retakes.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RetakesPlugin", "RetakesPlugin.csproj", "{49468CC6-92AF-4038-BE91-9FCE0687A989}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {49468CC6-92AF-4038-BE91-9FCE0687A989}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {49468CC6-92AF-4038-BE91-9FCE0687A989}.Debug|Any CPU.Build.0 = Debug|Any CPU + {49468CC6-92AF-4038-BE91-9FCE0687A989}.Release|Any CPU.ActiveCfg = Release|Any CPU + {49468CC6-92AF-4038-BE91-9FCE0687A989}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {49810708-A540-4920-B202-3DF5E65AFFB2} + EndGlobalSection +EndGlobal From 11653669268f33eed9f307d375e473d5b89346c2 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 14 Jan 2024 18:30:41 +0530 Subject: [PATCH 2/6] Updated the code a bit to easy it out. --- Modules/Managers/BreakerManager.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Modules/Managers/BreakerManager.cs b/Modules/Managers/BreakerManager.cs index 2285133..7f97d9c 100644 --- a/Modules/Managers/BreakerManager.cs +++ b/Modules/Managers/BreakerManager.cs @@ -35,8 +35,7 @@ private static void DestroyBreakables() var breakableEntities = Utilities.FindAllEntitiesByDesignerName("func_breakable") .Concat(Utilities.FindAllEntitiesByDesignerName("func_breakable_surf")) - .Concat(Utilities.FindAllEntitiesByDesignerName("prop_dynamic")) - ; + .Concat(Utilities.FindAllEntitiesByDesignerName("prop_dynamic")); foreach (var breakableEntity in breakableEntities) { From 432818727be263aa07ad0c849320b968bba2c871 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 14 Jan 2024 19:22:49 +0530 Subject: [PATCH 3/6] Breaker Manager is now working properly. --- Modules/Managers/BreakerManager.cs | 90 +++++++++++++++++++----------- RetakesPlugin.cs | 8 +-- 2 files changed, 60 insertions(+), 38 deletions(-) diff --git a/Modules/Managers/BreakerManager.cs b/Modules/Managers/BreakerManager.cs index 7f97d9c..63d9d76 100644 --- a/Modules/Managers/BreakerManager.cs +++ b/Modules/Managers/BreakerManager.cs @@ -30,51 +30,73 @@ public void Handle() } private static void DestroyBreakables() +{ + var breakableEntities = new List<(string designerName, string action, Type entityType)> { - // TODO: This is slow as balls, merge them into one loop of the entities. - var breakableEntities = - Utilities.FindAllEntitiesByDesignerName("func_breakable") - .Concat(Utilities.FindAllEntitiesByDesignerName("func_breakable_surf")) - .Concat(Utilities.FindAllEntitiesByDesignerName("prop_dynamic")); + ("func_breakable", "Break", typeof(CBreakable)), + ("func_breakable_surf", "Break", typeof(CBreakable)), + ("prop.breakable.01", "Break", typeof(CBreakableProp)), + ("prop.breakable.02", "Break", typeof(CBreakableProp)) + }; + + breakableEntities.AddRange( + Utilities.FindAllEntitiesByDesignerName("func_breakable") + .Select(entity => (entity.DesignerName, "Break", entity.GetType())) + ); + + breakableEntities.AddRange( + Utilities.FindAllEntitiesByDesignerName("func_breakable_surf") + .Select(entity => (entity.DesignerName, "Break", entity.GetType())) + ); - foreach (var breakableEntity in breakableEntities) + breakableEntities.AddRange( + Utilities.FindAllEntitiesByDesignerName("prop_dynamic") + .Select(entity => (entity.DesignerName, "Break", entity.GetType())) + ); + + if (Server.MapName == "de_vertigo" || Server.MapName == "de_cache" || Server.MapName == "de_nuke") + { + breakableEntities.Add(("prop_dynamic", "Break", typeof(CDynamicProp))); + } + + if (Server.MapName == "de_nuke") + { + breakableEntities.Add(("func_button", "Kill", typeof(CBaseButton))); + } + + foreach (var (designerName, action, entityType) in breakableEntities) +{ + IEnumerable entities = entityType switch + { + Type et when et == typeof(CBreakable) => Utilities.FindAllEntitiesByDesignerName(designerName), + Type et when et == typeof(CBreakableProp) => Utilities.FindAllEntitiesByDesignerName(designerName), + Type et when et == typeof(CDynamicProp) => Utilities.FindAllEntitiesByDesignerName(designerName), + Type et when et == typeof(CBaseButton) => Utilities.FindAllEntitiesByDesignerName(designerName), + _ => throw new InvalidOperationException("Unsupported entity type") + }; + + foreach (var entity in entities) + { + if (entity is CBreakable breakable) { - breakableEntity.AcceptInput("Break"); + breakable.AcceptInput("Break"); } - - // TODO: This is slow as balls, merge them into one loop of the entities. - var breakableProps = Utilities.FindAllEntitiesByDesignerName("prop.breakable.01") - .Concat(Utilities.FindAllEntitiesByDesignerName("prop.breakable.02")); - - foreach (var breakableProp in breakableProps) + else if (entity is CBreakableProp breakableProp) { - breakableProp.AcceptInput("break"); + breakableProp.AcceptInput("Break"); } - - if (Server.MapName == "de_vertigo" || Server.MapName == "de_cache" || Server.MapName == "de_nuke") + else if (entity is CDynamicProp dynamicProp) { - // TODO: This is slow as balls, merge them into one loop of the entities. - var dynamicProps = Utilities.FindAllEntitiesByDesignerName("prop_dynamic"); - - foreach (var dynamicProp in dynamicProps) - { - dynamicProp.AcceptInput("Break"); - } + dynamicProp.AcceptInput("Break"); } - - switch (Server.MapName) + else if (entity is CBaseButton baseButton) { - case "de_nuke": - // TODO: This is slow as balls, merge them into one loop of the entities. - var buttonEntities = Utilities.FindAllEntitiesByDesignerName("func_button"); - - foreach (var buttonEntity in buttonEntities) - { - buttonEntity.AcceptInput("Kill"); - } - break; + baseButton.AcceptInput("Break"); } } +} + +} private static void OpenDoors() { diff --git a/RetakesPlugin.cs b/RetakesPlugin.cs index 0d72591..d7ace4a 100644 --- a/RetakesPlugin.cs +++ b/RetakesPlugin.cs @@ -18,13 +18,13 @@ namespace RetakesPlugin; [MinimumApiVersion(131)] public class RetakesPlugin : BasePlugin { - private const string Version = "1.2.8"; + private const string Version = "1.2.9"; #region Plugin info - public override string ModuleName => "Retakes Plugin"; + public override string ModuleName => "Retakes & Breaker Plugin"; public override string ModuleVersion => Version; - public override string ModuleAuthor => "B3none"; - public override string ModuleDescription => "Community retakes for CS2."; + public override string ModuleAuthor => "B3none & KillerRoi"; + public override string ModuleDescription => "Community retakes & breaker for CS2."; #endregion #region Constants From ad75978b0aba8592071206e4abef2ba32c1b380b Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 14 Jan 2024 19:25:00 +0530 Subject: [PATCH 4/6] Bumped the verison to 1.2.9 --- RetakesPlugin.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RetakesPlugin.cs b/RetakesPlugin.cs index d7ace4a..af227ad 100644 --- a/RetakesPlugin.cs +++ b/RetakesPlugin.cs @@ -23,8 +23,8 @@ public class RetakesPlugin : BasePlugin #region Plugin info public override string ModuleName => "Retakes & Breaker Plugin"; public override string ModuleVersion => Version; - public override string ModuleAuthor => "B3none & KillerRoi"; - public override string ModuleDescription => "Community retakes & breaker for CS2."; + public override string ModuleAuthor => "B3none"; + public override string ModuleDescription => "Community retakes for CS2."; #endregion #region Constants From 00ed6109205d671ce066e5a4c58f8654de92fcdd Mon Sep 17 00:00:00 2001 From: B3none <24966460+B3none@users.noreply.github.com> Date: Sun, 14 Jan 2024 13:58:46 +0000 Subject: [PATCH 5/6] Revert plugin name change --- RetakesPlugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RetakesPlugin.cs b/RetakesPlugin.cs index af227ad..1f5c3b2 100644 --- a/RetakesPlugin.cs +++ b/RetakesPlugin.cs @@ -21,7 +21,7 @@ public class RetakesPlugin : BasePlugin private const string Version = "1.2.9"; #region Plugin info - public override string ModuleName => "Retakes & Breaker Plugin"; + public override string ModuleName => "Retakes Plugin"; public override string ModuleVersion => Version; public override string ModuleAuthor => "B3none"; public override string ModuleDescription => "Community retakes for CS2."; From e58e7fb0f67d9f9cdca0477b07248602c1c647bf Mon Sep 17 00:00:00 2001 From: B3none <24966460+B3none@users.noreply.github.com> Date: Sun, 14 Jan 2024 13:59:01 +0000 Subject: [PATCH 6/6] Delete cs2-retakes.sln --- cs2-retakes.sln | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 cs2-retakes.sln diff --git a/cs2-retakes.sln b/cs2-retakes.sln deleted file mode 100644 index 4fb87ba..0000000 --- a/cs2-retakes.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.002.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RetakesPlugin", "RetakesPlugin.csproj", "{49468CC6-92AF-4038-BE91-9FCE0687A989}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {49468CC6-92AF-4038-BE91-9FCE0687A989}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {49468CC6-92AF-4038-BE91-9FCE0687A989}.Debug|Any CPU.Build.0 = Debug|Any CPU - {49468CC6-92AF-4038-BE91-9FCE0687A989}.Release|Any CPU.ActiveCfg = Release|Any CPU - {49468CC6-92AF-4038-BE91-9FCE0687A989}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {49810708-A540-4920-B202-3DF5E65AFFB2} - EndGlobalSection -EndGlobal