2022-05-17 03:13:41 +03:00
|
|
|
#include "pch-il2cpp.h"
|
|
|
|
#include "Entity.h"
|
|
|
|
|
|
|
|
#include <helpers.h>
|
|
|
|
#include "EntityManager.h"
|
|
|
|
|
|
|
|
namespace cheat::game
|
|
|
|
{
|
|
|
|
|
|
|
|
Entity::Entity(app::BaseEntity* rawEntity) : m_RawEntity(rawEntity), m_Name({}), m_HasName(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
app::String* GetRawName(game::Entity* entity)
|
|
|
|
{
|
|
|
|
SAFE_BEGIN();
|
2022-05-29 22:51:08 +03:00
|
|
|
return app::MoleMole_BaseEntity_ToStringRelease(entity->raw(), nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
SAFE_ERROR();
|
|
|
|
return nullptr;
|
|
|
|
SAFE_END();
|
|
|
|
}
|
|
|
|
std::string& Entity::name()
|
|
|
|
{
|
|
|
|
if (m_HasName || m_RawEntity == nullptr || !isLoaded())
|
|
|
|
return m_Name;
|
|
|
|
|
|
|
|
auto rawName = GetRawName(this);
|
|
|
|
if (rawName == nullptr)
|
|
|
|
return m_Name;
|
|
|
|
|
|
|
|
auto name = il2cppi_to_string(rawName);
|
|
|
|
m_Name = name;
|
|
|
|
m_HasName = true;
|
|
|
|
return m_Name;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
app::BaseEntity* Entity::raw()
|
|
|
|
{
|
|
|
|
return m_RawEntity;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t Entity::runtimeID()
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return m_RawEntity->fields._runtimeID_k__BackingField;
|
|
|
|
}
|
|
|
|
|
|
|
|
app::EntityType__Enum_1 Entity::type()
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return app::EntityType__Enum_1::None;
|
|
|
|
|
|
|
|
return m_RawEntity->fields.entityType;
|
|
|
|
}
|
|
|
|
|
|
|
|
app::Vector3 Entity::relativePosition()
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return {};
|
|
|
|
|
2022-05-29 22:51:08 +03:00
|
|
|
return app::MoleMole_BaseEntity_GetRelativePosition(m_RawEntity, nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
app::Vector3 Entity::absolutePosition()
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return {};
|
|
|
|
|
2022-05-29 22:51:08 +03:00
|
|
|
return app::MoleMole_BaseEntity_GetAbsolutePosition(m_RawEntity, nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
app::Vector2 Entity::levelPosition()
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return {};
|
|
|
|
|
2022-05-28 04:21:08 -06:00
|
|
|
return app::Miscs_GenLevelPos_1(absolutePosition(), nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
float Entity::distance(Entity* entity)
|
|
|
|
{
|
|
|
|
if (entity == nullptr)
|
|
|
|
return 10000;
|
|
|
|
|
|
|
|
return distance(entity->relativePosition());
|
|
|
|
}
|
|
|
|
|
|
|
|
float Entity::distance(app::BaseEntity* rawEntity)
|
|
|
|
{
|
|
|
|
if (rawEntity == nullptr)
|
|
|
|
return 10000;
|
|
|
|
|
2022-05-29 22:51:08 +03:00
|
|
|
auto point = app::MoleMole_BaseEntity_GetRelativePosition(rawEntity, nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
return distance(point);
|
|
|
|
}
|
|
|
|
|
|
|
|
float Entity::distance(const app::Vector3& point)
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return 10000;
|
|
|
|
|
2022-05-28 04:21:08 -06:00
|
|
|
auto dist = app::Vector3_Distance(relativePosition(), point, nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
return dist;
|
|
|
|
}
|
|
|
|
|
|
|
|
float Entity::distance(const app::Vector2& levelPoint)
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return 10000;
|
|
|
|
|
2022-05-28 04:21:08 -06:00
|
|
|
return app::Vector2_Distance(levelPosition(), levelPoint, nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Entity::isGadget()
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return m_RawEntity->fields.entityType == app::EntityType__Enum_1::Gadget ||
|
|
|
|
m_RawEntity->fields.entityType == app::EntityType__Enum_1::Bullet ||
|
|
|
|
m_RawEntity->fields.entityType == app::EntityType__Enum_1::Field;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Entity::isChest()
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return m_RawEntity->fields.entityType == app::EntityType__Enum_1::Chest;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Entity::isAvatar()
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto avatar = EntityManager::instance().avatar();
|
|
|
|
if (avatar->raw() == nullptr)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return avatar->raw() == m_RawEntity;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Entity::setRelativePosition(const app::Vector3& value)
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return;
|
|
|
|
|
2022-05-29 22:51:08 +03:00
|
|
|
app::MoleMole_BaseEntity_SetRelativePosition(m_RawEntity, value, true, nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Entity::setAbsolutePosition(const app::Vector3& value)
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return;
|
|
|
|
|
2022-05-29 22:51:08 +03:00
|
|
|
app::MoleMole_BaseEntity_SetAbsolutePosition(m_RawEntity, value, true, nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Entity::isLoaded()
|
|
|
|
{
|
2022-05-29 22:51:08 +03:00
|
|
|
if (m_RawEntity == nullptr || !app::MoleMole_BaseEntity_IsActive(m_RawEntity, nullptr))
|
2022-05-17 03:13:41 +03:00
|
|
|
return false;
|
|
|
|
|
2022-05-29 22:51:08 +03:00
|
|
|
m_IsLoaded = m_IsLoaded || app::MoleMole_BaseEntity_get_rootGameObject(m_RawEntity, nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
return m_IsLoaded;
|
|
|
|
}
|
|
|
|
|
|
|
|
app::VCBaseMove* Entity::moveComponent()
|
|
|
|
{
|
|
|
|
if (!isLoaded())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
SAFE_BEGIN();
|
2022-05-29 22:51:08 +03:00
|
|
|
return app::MoleMole_BaseEntity_GetMoveComponent_1(m_RawEntity, *app::MoleMole_BaseEntity_GetMoveComponent_1__MethodInfo);
|
2022-05-17 03:13:41 +03:00
|
|
|
SAFE_ERROR();
|
|
|
|
return nullptr;
|
|
|
|
SAFE_END();
|
|
|
|
}
|
|
|
|
|
|
|
|
app::LCBaseCombat* Entity::combat()
|
|
|
|
{
|
|
|
|
if (!isLoaded())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
SAFE_BEGIN();
|
2022-05-29 22:51:08 +03:00
|
|
|
return app::MoleMole_BaseEntity_GetLogicCombatComponent_1(m_RawEntity, *app::MoleMole_BaseEntity_GetLogicCombatComponent_1__MethodInfo);
|
2022-05-17 03:13:41 +03:00
|
|
|
SAFE_ERROR();
|
|
|
|
return nullptr;
|
|
|
|
SAFE_END();
|
|
|
|
}
|
|
|
|
|
|
|
|
app::Rigidbody* Entity::rigidbody()
|
|
|
|
{
|
|
|
|
if (!isLoaded())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
SAFE_BEGIN();
|
2022-05-29 22:51:08 +03:00
|
|
|
return app::MoleMole_BaseEntity_GetRigidbody(m_RawEntity, nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
SAFE_ERROR();
|
|
|
|
return nullptr;
|
|
|
|
SAFE_END();
|
|
|
|
}
|
|
|
|
|
2022-07-24 21:24:36 -06:00
|
|
|
app::Animator* Entity::animator()
|
|
|
|
{
|
|
|
|
if (!isLoaded())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
SAFE_BEGIN();
|
|
|
|
return app::MoleMole_BaseEntity_get_animator(m_RawEntity, nullptr);
|
|
|
|
SAFE_ERROR();
|
|
|
|
return nullptr;
|
|
|
|
SAFE_END();
|
|
|
|
}
|
|
|
|
|
2022-05-17 03:13:41 +03:00
|
|
|
app::GameObject* Entity::gameObject()
|
|
|
|
{
|
|
|
|
if (!isLoaded())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
SAFE_BEGIN();
|
2022-05-29 22:51:08 +03:00
|
|
|
return app::MoleMole_BaseEntity_get_gameObject(m_RawEntity, nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
SAFE_ERROR();
|
|
|
|
return nullptr;
|
|
|
|
SAFE_END();
|
|
|
|
}
|
|
|
|
|
|
|
|
app::Vector3 Entity::forward()
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return {};
|
|
|
|
|
2022-05-29 22:51:08 +03:00
|
|
|
return app::MoleMole_BaseEntity_GetForward(m_RawEntity, nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
app::Vector3 Entity::back()
|
|
|
|
{
|
|
|
|
return -forward();
|
|
|
|
}
|
|
|
|
|
|
|
|
app::Vector3 Entity::right()
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return {};
|
|
|
|
|
2022-05-29 22:51:08 +03:00
|
|
|
return app::MoleMole_BaseEntity_GetRight(m_RawEntity, nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
app::Vector3 Entity::left()
|
|
|
|
{
|
|
|
|
return -right();
|
|
|
|
}
|
|
|
|
|
|
|
|
app::Vector3 Entity::up()
|
|
|
|
{
|
|
|
|
if (m_RawEntity == nullptr)
|
|
|
|
return {};
|
|
|
|
|
2022-05-29 22:51:08 +03:00
|
|
|
return app::MoleMole_BaseEntity_GetUp(m_RawEntity, nullptr);
|
2022-05-17 03:13:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
app::Vector3 Entity::down()
|
|
|
|
{
|
|
|
|
return -up();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|