mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 20:11:50 +00:00
refactor and cleanup player controller
This commit is contained in:
parent
487ba84517
commit
3cd0261f3b
8 changed files with 21 additions and 13 deletions
|
|
@ -40,10 +40,11 @@ void LevelController::update(float delta, bool input, bool pause) {
|
|||
}
|
||||
}
|
||||
blocks->update(delta);
|
||||
player->update(delta, input, pause);
|
||||
level->entities->updatePhysics(delta);
|
||||
level->entities->update();
|
||||
}
|
||||
player->update(delta, input, pause);
|
||||
player->postUpdate(delta, input, pause);
|
||||
|
||||
// erease null pointers
|
||||
level->objects.erase(
|
||||
|
|
|
|||
|
|
@ -239,11 +239,16 @@ void PlayerController::update(float delta, bool input, bool pause) {
|
|||
} else {
|
||||
resetKeyboard();
|
||||
}
|
||||
updatePlayer(delta);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerController::postUpdate(float delta, bool input, bool pause) {
|
||||
if (!pause) {
|
||||
updateFootsteps(delta);
|
||||
updateCamera(delta, input);
|
||||
updatePlayer(delta);
|
||||
|
||||
}
|
||||
player->postUpdate(this->input, delta);
|
||||
camControl.refresh();
|
||||
if (input) {
|
||||
updateInteraction();
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public:
|
|||
BlocksController* blocksController
|
||||
);
|
||||
void update(float delta, bool input, bool pause);
|
||||
|
||||
void postUpdate(float delta, bool input, bool pause);
|
||||
Player* getPlayer();
|
||||
|
||||
void listenBlockInteraction(const on_block_interaction& callback);
|
||||
|
|
|
|||
|
|
@ -286,11 +286,10 @@ void scripting::on_entity_spawn(
|
|||
lua::call(L, 1);
|
||||
}
|
||||
if (components.size() > 1) {
|
||||
for (int i = 0; i < components.size()-1; i++) {
|
||||
for (size_t i = 0; i < components.size()-1; i++) {
|
||||
lua::pushvalue(L, -1);
|
||||
}
|
||||
}
|
||||
std::cout << "entity duplicated " << (components.size()-1) << " times" << std::endl;
|
||||
for (auto& component : components) {
|
||||
auto compenv = create_component_environment(get_root_environment(), -1,
|
||||
component->name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue