This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/src/util/world_model.hpp

32 lines
735 B
C++
Raw Normal View History

2022-09-20 14:51:43 +02:00
#pragma once
#include "natives.hpp"
#include "pointers.hpp"
#include "script.hpp"
2022-09-20 14:51:43 +02:00
struct world_model_bypass
2022-09-20 14:51:43 +02:00
{
inline static memory::byte_patch* m_world_model_spawn_bypass;
};
2022-09-20 14:51:43 +02:00
namespace big::world_model
{
2022-09-20 14:51:43 +02:00
inline Object spawn(Hash hash, Vector3 location = Vector3(), bool is_networked = true)
{
if (entity::request_model(hash))
2022-09-20 14:51:43 +02:00
{
world_model_bypass::m_world_model_spawn_bypass->apply();
2022-09-20 14:51:43 +02:00
const auto object = OBJECT::CREATE_OBJECT(hash, location.x, location.y, location.z, is_networked, false, false);
2022-09-20 14:51:43 +02:00
world_model_bypass::m_world_model_spawn_bypass->restore();
2022-09-20 14:51:43 +02:00
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(hash);
2022-09-20 14:51:43 +02:00
return object;
}
2022-09-20 14:51:43 +02:00
LOG(WARNING) << "Failed to load model " << HEX_TO_UPPER(hash);
return 0;
2022-09-20 14:51:43 +02:00
}
}