mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
[Enhancement]: Stability Improvements to Black Hole Feature (#3132)
This commit is contained in:
parent
f28883a05f
commit
e29928ef46
@ -11,27 +11,41 @@ namespace big
|
||||
{
|
||||
using looped_command::looped_command;
|
||||
|
||||
std::vector<Entity> entity_list;
|
||||
std::chrono::steady_clock::time_point last_call_time;
|
||||
|
||||
virtual void on_tick() override
|
||||
{
|
||||
for (auto entity : entity::get_entities(g.world.blackhole.include_vehicles, g.world.blackhole.include_peds))
|
||||
auto current_time = std::chrono::steady_clock::now();
|
||||
auto elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(current_time - last_call_time).count();
|
||||
|
||||
if (elapsed_time >= 1000) // Reduce black hole gather spam so it pulses only every second
|
||||
{
|
||||
if (entity::take_control_of(entity, 0))
|
||||
entity_list = entity::get_entities(g.world.blackhole.include_vehicles, g.world.blackhole.include_peds);
|
||||
last_call_time = current_time;
|
||||
|
||||
for (int i = 0; i < 30 && i < entity_list.size(); i++) // Only yeet up to 30 entities every second to prevent crashes
|
||||
{
|
||||
auto entity_coord = ENTITY::GET_ENTITY_COORDS(entity, false);
|
||||
ENTITY::APPLY_FORCE_TO_ENTITY(entity,
|
||||
1,
|
||||
((g.world.blackhole.pos.x - entity_coord.x) * 9.f),
|
||||
((g.world.blackhole.pos.y - entity_coord.y) * 9.f),
|
||||
((g.world.blackhole.pos.z - entity_coord.z) * 9.f),
|
||||
0.f,
|
||||
0.f,
|
||||
0.f,
|
||||
0,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
0,
|
||||
0);
|
||||
auto entity = entity_list[i];
|
||||
|
||||
if (entity::take_control_of(entity, 0))
|
||||
{
|
||||
auto entity_coord = ENTITY::GET_ENTITY_COORDS(entity, false);
|
||||
ENTITY::APPLY_FORCE_TO_ENTITY(entity,
|
||||
1,
|
||||
((g.world.blackhole.pos.x - entity_coord.x) * 9.f),
|
||||
((g.world.blackhole.pos.y - entity_coord.y) * 9.f),
|
||||
((g.world.blackhole.pos.z - entity_coord.z) * 9.f),
|
||||
0.f,
|
||||
0.f,
|
||||
0.f,
|
||||
0,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,6 +78,8 @@ namespace big
|
||||
};
|
||||
|
||||
blackhole g_blackhole("blackhole", "GUI_TAB_BLACKHOLE", "BACKEND_LOOPED_WORLD_BLACKHOLE_DESC", g.world.blackhole.enable);
|
||||
bool_command g_blackhole_peds("blackholeincpeds", "PEDS", "BACKEND_LOOPED_WORLD_BLACKHOLE_PEDS_DESC", g.world.blackhole.include_peds);
|
||||
bool_command g_blackhole_vehicles("blackholeincvehs", "VEHICLES", "BACKEND_LOOPED_WORLD_BLACKHOLE_VEHS_DESC", g.world.blackhole.include_vehicles);
|
||||
bool_command
|
||||
g_blackhole_peds("blackholeincpeds", "PEDS", "BACKEND_LOOPED_WORLD_BLACKHOLE_PEDS_DESC", g.world.blackhole.include_peds);
|
||||
bool_command g_blackhole_vehicles("blackholeincvehs", "VEHICLES", "BACKEND_LOOPED_WORLD_BLACKHOLE_VEHS_DESC",
|
||||
g.world.blackhole.include_vehicles);
|
||||
}
|
Loading…
Reference in New Issue
Block a user