mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 20:11:50 +00:00
add on_player_set entity component event
This commit is contained in:
parent
8d7fab1f2f
commit
e4a11f182e
9 changed files with 29 additions and 15 deletions
|
|
@ -82,7 +82,6 @@ void LevelController::update(float delta, bool pause) {
|
|||
continue;
|
||||
}
|
||||
player->rotationInterpolation.updateTimer(delta);
|
||||
player->updateEntity();
|
||||
glm::vec3 position = player->getPosition();
|
||||
player->chunks->configure(
|
||||
glm::floor(position.x),
|
||||
|
|
@ -96,9 +95,9 @@ void LevelController::update(float delta, bool pause) {
|
|||
*player,
|
||||
player.get() == clientPlayer
|
||||
);
|
||||
player->updateEntity();
|
||||
}
|
||||
if (!pause) {
|
||||
// update all objects that needed
|
||||
blocks->update(delta, settings.chunks.padding.get());
|
||||
level->entities->update(delta);
|
||||
for (const auto& [_, player] : *level->players) {
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ namespace scripting {
|
|||
void on_entity_grounded(const Entity& entity, float force);
|
||||
void on_entity_fall(const Entity& entity);
|
||||
void on_entity_save(const Entity& entity);
|
||||
void on_entity_player_set(const Entity& entity, int64_t pid);
|
||||
void on_entities_update(int tps, int parts, int part);
|
||||
void on_entities_physics_update(float delta);
|
||||
void on_entities_render(float delta);
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ static void init_component_events(
|
|||
funcsset.on_aim_off = lua::hasfield(L, "on_aim_off");
|
||||
funcsset.on_attacked = lua::hasfield(L, "on_attacked");
|
||||
funcsset.on_used = lua::hasfield(L, "on_used");
|
||||
funcsset.on_player_set = lua::hasfield(L, "on_player_set");
|
||||
lua::pop(L);
|
||||
}
|
||||
|
||||
|
|
@ -238,6 +239,15 @@ void scripting::on_entity_save(const Entity& entity) {
|
|||
);
|
||||
}
|
||||
|
||||
void scripting::on_entity_player_set(const Entity& entity, int64_t pid) {
|
||||
process_entity_callback(
|
||||
entity,
|
||||
"on_player_set",
|
||||
&EntityFuncsSet::on_player_set,
|
||||
[pid](auto L) { return lua::pushinteger(L, pid); }
|
||||
);
|
||||
}
|
||||
|
||||
void scripting::on_sensor_enter(
|
||||
const Entity& entity, size_t index, entityid_t oid
|
||||
) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue