39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
#include "Common.h"
|
|
#include "GLM.h"
|
|
#include "Core/System.h"
|
|
#include "Core/EPlayerSpawned.h"
|
|
#include "Input/FirstPersonInputController.h"
|
|
#include <imgui/imgui.h>
|
|
#include "Events/EDoubleJump.h"
|
|
#include "../Engine/Sound/EPlaySoundOnEntity.h"
|
|
|
|
class PlayerMovementSystem : public ImpureSystem, PureSystem
|
|
{
|
|
public:
|
|
PlayerMovementSystem(World* world, EventBroker* eventBroker);
|
|
~PlayerMovementSystem();
|
|
|
|
virtual void Update(double dt) override;
|
|
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt);
|
|
|
|
private:
|
|
// State
|
|
std::unordered_map<EntityWrapper, FirstPersonInputController<PlayerMovementSystem>*> m_PlayerInputControllers;
|
|
|
|
EntityWrapper m_LocalPlayer = EntityWrapper::Invalid;
|
|
// Walking logic
|
|
// Keeps track of how far the player has walked within this "key press session".
|
|
float m_DistanceMoved = 0.0f;
|
|
// How far a step is (How often the step sound will be played).
|
|
const float m_PlayerStepLength = 1.75f;
|
|
// Determine what sound file to play.
|
|
bool m_LeftFoot = false;
|
|
// To get a difference when calculating the walking state.
|
|
glm::vec3 m_LastPosition = glm::vec3();
|
|
// The logic for making the sound play when player is moving
|
|
void playerStep(double dt);
|
|
|
|
EventRelay<PlayerMovementSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
|
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
|
|
|
}; |