add on_player_set entity component event

This commit is contained in:
MihailRis 2026-07-18 19:09:43 +03:00
parent 8d7fab1f2f
commit e4a11f182e
9 changed files with 29 additions and 15 deletions

View file

@ -113,6 +113,11 @@ int64_t Entity::getPlayer() const {
}
void Entity::setPlayer(int64_t id) {
registry.get<EntityId>(entity).player = id;
auto& eid = registry.get<EntityId>(entity);
if (eid.player == id) {
return;
}
eid.player = id;
scripting::on_entity_player_set(*this, id);
}

View file

@ -81,7 +81,7 @@ void Player::updateEntity() {
}
}
Hitbox* Player::getHitbox() {
Hitbox* Player::getHitbox() const {
if (auto entity = level.entities->get(eid)) {
return &entity->getRigidbody().hitbox;
}

View file

@ -135,7 +135,7 @@ public:
bool isCurrentCameraBuiltin() const;
Hitbox* getHitbox();
Hitbox* getHitbox() const;
void setSpawnPoint(glm::vec3 point);
glm::vec3 getSpawnPoint() const;

View file

@ -17,6 +17,7 @@ struct EntityFuncsSet {
bool on_aim_off;
bool on_attacked;
bool on_used;
bool on_player_set;
};
struct UserComponent {