remove EnTT from Entities.cpp

This commit is contained in:
MihailRis 2026-11-01 02:24:15 +03:00
parent 0ae335599a
commit 7ef07a75cd
11 changed files with 215 additions and 223 deletions

View file

@ -498,11 +498,11 @@ void PlayerController::processRightClick(
void PlayerController::updateEntityInteraction(
entityid_t eid, bool lclick, bool rclick
) {
auto entityOpt = level.entities->get(eid);
if (!entityOpt.has_value()) {
auto entityPtr = level.entities->get(eid);
if (entityPtr == nullptr) {
return;
}
auto entity = *entityOpt;
const auto& entity = *entityPtr;
if (lclick) {
scripting::on_attacked(entity, &player, player.getEntity());
}

View file

@ -28,7 +28,7 @@ static const EntityDef* require_entity_def(lua::State* L) {
}
static int l_exists(lua::State* L) {
return lua::pushboolean(L, get_entity(L, 1).has_value());
return lua::pushboolean(L, get_entity(L, 1) != nullptr);
}
static int l_def_index(lua::State* L) {
@ -138,8 +138,7 @@ static int l_get_all_in_box(lua::State* L) {
auto found = level->entities->getAllInside(AABB(pos, pos + size));
lua::createtable(L, found.size(), 0);
for (size_t i = 0; i < found.size(); i++) {
const auto& entity = found[i];
lua::pushinteger(L, entity.getUID());
lua::pushinteger(L, found[i]->getUID());
lua::rawseti(L, i + 1);
}
return 1;
@ -151,8 +150,7 @@ static int l_get_all_in_radius(lua::State* L) {
auto found = level->entities->getAllInRadius(pos, radius);
lua::createtable(L, found.size(), 0);
for (size_t i = 0; i < found.size(); i++) {
const auto& entity = found[i];
lua::pushinteger(L, entity.getUID());
lua::pushinteger(L, found[i]->getUID());
lua::rawseti(L, i + 1);
}
return 1;

View file

@ -1,7 +1,5 @@
#pragma once
#include <optional>
#include "frontend/hud.hpp"
#include "objects/Entities.hpp"
#include "objects/Entity.hpp"
@ -13,7 +11,7 @@ namespace scripting {
extern Hud* hud;
}
inline std::optional<Entity> get_entity(lua::State* L, int idx) {
inline Entity* get_entity(lua::State* L, int idx) {
auto id = lua::tointeger(L, idx);
auto level = scripting::controller->getLevel();
return level->entities->get(id);