Skip to content

Commit

Permalink
Update entity.h
Browse files Browse the repository at this point in the history
  • Loading branch information
zpl-zak committed Aug 27, 2024
1 parent c2f7944 commit 590b260
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,25 @@ namespace Framework::Integrations::Scripting {
protected:
flecs::entity _ent {};

public:
Entity(flecs::entity ent) {
_ent = ent;

void ValidateEntity() {
if (!_ent.is_valid() || !_ent.is_alive()) {
throw std::runtime_error(fmt::format("[Scripting] Entity handle '{}' is invalid!", ent));
throw std::runtime_error(fmt::format("Entity handle '{}' is invalid!", _ent.id()));
}

const auto st = _ent.get<Framework::World::Modules::Base::Streamable>();
if (!st) {
throw std::runtime_error(fmt::format("[Scripting] Entity '{}' is protected!", ent));
throw std::runtime_error(fmt::format("Entity '{}' is protected!", _ent.id()));
}
}
public:
Entity(flecs::entity ent) {
_ent = ent;
ValidateEntity();
}

Entity(flecs::entity_t ent) {
Entity(flecs::entity(CoreModules::GetWorldEngine()->GetWorld()->get_world(), ent));
_ent = flecs::entity(CoreModules::GetWorldEngine()->GetWorld()->get_world(), ent);
ValidateEntity();
}

flecs::entity_t GetID() const {
Expand Down

0 comments on commit 590b260

Please sign in to comment.