Added nearby entity deletion (#1476)

This commit is contained in:
DayibBaba
2023-06-21 10:01:00 +02:00
committed by GitHub
parent 5d3620a67c
commit 70c4b0c63b
4 changed files with 86 additions and 10 deletions

View File

@ -1,5 +1,6 @@
#include "util/entity.hpp"
#include "util/local_player.hpp"
#include "util/notify.hpp"
#include "util/ped.hpp"
#include "util/vehicle.hpp"
#include "views/view.hpp"
@ -43,13 +44,12 @@ namespace big
ImGui::SameLine(140.f);
components::command_checkbox<"pedrush">();
components::command_checkbox<"autodisarm">();
components::options_modal("Auto Disarm", []{
components::options_modal("Auto Disarm", [] {
ImGui::Checkbox("Neutralize", &g.world.nearby.auto_disarm.neutralize);
});
ImGui::Separator();
components::sub_title("Vehicles");
// Nearby Vehicle Actions
components::button<ImVec2(110, 0), ImVec4(0.02745f, 0.4745f, 0.10196f, 1.f)>("Max Upgrade", [] {
for (auto vehs : entity::get_entities(true, false))
@ -75,5 +75,67 @@ namespace big
});
components::command_checkbox<"vehiclerain">();
ImGui::Separator();
components::sub_title("All");
static bool included_entity_types[3];
static bool own_vehicle, deleting;
static int quantity, remaining;
ImGui::Text("Include:");
ImGui::Checkbox("Vehicles", &included_entity_types[0]);
ImGui::SameLine();
ImGui::Checkbox("Peds", &included_entity_types[1]);
ImGui::SameLine();
ImGui::Checkbox("Props", &included_entity_types[2]);
if (included_entity_types[0])
ImGui::Checkbox("Self vehicle", &own_vehicle);
if (deleting)
{
float progress = 1 - static_cast<float>(remaining) / quantity;
ImGui::ProgressBar(progress, ImVec2(200, 25));
}
else
{
components::button("Delete all", [&] {
auto list = entity::get_entities(included_entity_types[0], included_entity_types[1], included_entity_types[2], own_vehicle);
quantity = list.size();
remaining = quantity;
g_notification_service->push("Entity deletion", std::format("Deleting {} entities", quantity));
deleting = true;
int failed = 0;
for (auto ent : list)
{
if (ent == self::ped)
continue;
if (ENTITY::DOES_ENTITY_EXIST(ent))
{
if (ENTITY::IS_ENTITY_A_VEHICLE(ent))
if (ent == self::veh && own_vehicle)
TASK::CLEAR_PED_TASKS_IMMEDIATELY(self::ped);
if (entity::take_control_of(ent, 25))
entity::delete_entity(ent);
}
script::get_current()->yield(5ms);
if (ENTITY::DOES_ENTITY_EXIST(ent))
failed++;
else
remaining--;
}
if (failed > 0)
g_notification_service->push_warning("Entity deletion", std::format("Failed deleting {} entities", failed));
deleting = false;
});
}
}
}