From 89231ccf42a21eb007459dd81538372dd7d2d884 Mon Sep 17 00:00:00 2001 From: Gray <84999745+Milxnor@users.noreply.github.com> Date: Sun, 14 Jan 2024 14:26:44 -0500 Subject: [PATCH] fixed destroy all player builds --- Project Reboot 3.0/NetDriver.cpp | 18 ++++++++++++++++++ Project Reboot 3.0/gui.h | 15 ++------------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Project Reboot 3.0/NetDriver.cpp b/Project Reboot 3.0/NetDriver.cpp index 57a4710..713c7bf 100644 --- a/Project Reboot 3.0/NetDriver.cpp +++ b/Project Reboot 3.0/NetDriver.cpp @@ -31,6 +31,24 @@ void UNetDriver::RemoveNetworkActor(AActor* Actor) void UNetDriver::TickFlushHook(UNetDriver* NetDriver) { + if (bShouldDestroyAllPlayerBuilds) // i hate this + { + auto AllBuildingSMActors = UGameplayStatics::GetAllActorsOfClass(GetWorld(), ABuildingSMActor::StaticClass()); + + for (int i = 0; i < AllBuildingSMActors.Num(); i++) + { + auto CurrentBuildingSMActor = (ABuildingSMActor*)AllBuildingSMActors.at(i); + + if (CurrentBuildingSMActor->IsDestroyed() || CurrentBuildingSMActor->IsActorBeingDestroyed() || !CurrentBuildingSMActor->IsPlayerPlaced()) continue; + + CurrentBuildingSMActor->SilentDie(); + // CurrentBuildingSMActor->K2_DestroyActor(); + } + + AllBuildingSMActors.Free(); + bShouldDestroyAllPlayerBuilds = false; + } + /* if (bEnableBotTick) { Bots::Tick(); diff --git a/Project Reboot 3.0/gui.h b/Project Reboot 3.0/gui.h index 43a26bd..17e3af8 100644 --- a/Project Reboot 3.0/gui.h +++ b/Project Reboot 3.0/gui.h @@ -87,6 +87,7 @@ extern inline int AmountOfBotsToSpawn = 0; extern inline bool bEnableRebooting = false; extern inline bool bEngineDebugLogs = false; extern inline bool bStartedBus = false; +extern inline bool bShouldDestroyAllPlayerBuilds = false; extern inline int AmountOfHealthSiphon = 0; // THE BASE CODE IS FROM IMGUI GITHUB @@ -1080,19 +1081,7 @@ static inline void MainUI() if (ImGui::Button("Destroy all player builds")) { - auto AllBuildingSMActors = UGameplayStatics::GetAllActorsOfClass(GetWorld(), ABuildingSMActor::StaticClass()); - - for (int i = 0; i < AllBuildingSMActors.Num(); i++) - { - auto CurrentBuildingSMActor = (ABuildingSMActor*)AllBuildingSMActors.at(i); - - if (CurrentBuildingSMActor->IsDestroyed() || CurrentBuildingSMActor->IsActorBeingDestroyed() || !CurrentBuildingSMActor->IsPlayerPlaced()) continue; - - CurrentBuildingSMActor->SilentDie(); - // CurrentBuildingSMActor->K2_DestroyActor(); - } - - AllBuildingSMActors.Free(); + bShouldDestroyAllPlayerBuilds = true; } if (ImGui::Button("Give Item to Everyone"))