mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
refactor PlayerController
This commit is contained in:
parent
1777600275
commit
315b4b44e1
3 changed files with 12 additions and 11 deletions
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "content/Content.hpp"
|
||||
#include "core_defs.hpp"
|
||||
#include "engine.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "items/Inventory.hpp"
|
||||
#include "items/ItemDef.hpp"
|
||||
#include "items/ItemStack.hpp"
|
||||
|
|
@ -189,12 +189,12 @@ void CameraControl::update(PlayerInput input, float delta, Chunks* chunks) {
|
|||
}
|
||||
|
||||
PlayerController::PlayerController(
|
||||
Engine* engine, Level* level,
|
||||
const EngineSettings& settings, Level* level,
|
||||
BlocksController* blocksController
|
||||
)
|
||||
: engine(engine), level(level),
|
||||
: settings(settings), level(level),
|
||||
player(level->getObject<Player>(0)),
|
||||
camControl(player, engine->getSettings().camera),
|
||||
camControl(player, settings.camera),
|
||||
blocksController(blocksController) {
|
||||
}
|
||||
|
||||
|
|
@ -263,7 +263,7 @@ void PlayerController::postUpdate(float delta, bool input, bool pause) {
|
|||
player->postUpdate();
|
||||
camControl.update(this->input, pause ? 0.0f : delta, level->chunks.get());
|
||||
if (input) {
|
||||
updateInteraction();
|
||||
updateInteraction(delta);
|
||||
} else {
|
||||
player->selection = {};
|
||||
}
|
||||
|
|
@ -481,13 +481,13 @@ void PlayerController::updateEntityInteraction(
|
|||
}
|
||||
}
|
||||
|
||||
void PlayerController::updateInteraction() {
|
||||
void PlayerController::updateInteraction(float delta) {
|
||||
auto indices = level->content->getIndices();
|
||||
auto chunks = level->chunks.get();
|
||||
const auto& selection = player->selection;
|
||||
|
||||
if (interactionTimer > 0.0f) {
|
||||
interactionTimer -= static_cast<float>(engine->getDelta());
|
||||
interactionTimer -= delta;
|
||||
}
|
||||
bool xkey = Events::active(BIND_PLAYER_FAST_INTERACTOIN);
|
||||
float maxDistance = xkey ? 200.0f : 10.0f;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue