mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 17:43:52 +00:00
Add WoW-style footsteps and improve third-person movement/collision
This commit is contained in:
parent
54dc27c2ec
commit
dfb1f3cfdc
11 changed files with 724 additions and 85 deletions
65
include/audio/footstep_manager.hpp
Normal file
65
include/audio/footstep_manager.hpp
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <random>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sys/types.h>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline { class AssetManager; }
|
||||
|
||||
namespace audio {
|
||||
|
||||
enum class FootstepSurface : uint8_t {
|
||||
STONE = 0,
|
||||
DIRT,
|
||||
GRASS,
|
||||
WOOD,
|
||||
METAL,
|
||||
WATER,
|
||||
SNOW
|
||||
};
|
||||
|
||||
class FootstepManager {
|
||||
public:
|
||||
FootstepManager();
|
||||
~FootstepManager();
|
||||
|
||||
bool initialize(pipeline::AssetManager* assets);
|
||||
void shutdown();
|
||||
|
||||
void update(float deltaTime);
|
||||
void playFootstep(FootstepSurface surface, bool sprinting);
|
||||
|
||||
bool isInitialized() const { return assetManager != nullptr; }
|
||||
bool hasAnySamples() const { return sampleCount > 0; }
|
||||
|
||||
private:
|
||||
struct Sample {
|
||||
std::string path;
|
||||
std::vector<uint8_t> data;
|
||||
};
|
||||
|
||||
struct SurfaceSamples {
|
||||
std::vector<Sample> clips;
|
||||
};
|
||||
|
||||
void preloadSurface(FootstepSurface surface, const std::vector<std::string>& candidates);
|
||||
void stopCurrentProcess();
|
||||
void reapFinishedProcess();
|
||||
bool playRandomStep(FootstepSurface surface, bool sprinting);
|
||||
static const char* surfaceName(FootstepSurface surface);
|
||||
|
||||
pipeline::AssetManager* assetManager = nullptr;
|
||||
SurfaceSamples surfaces[7];
|
||||
size_t sampleCount = 0;
|
||||
|
||||
std::string tempFilePath = "/tmp/wowee_footstep.wav";
|
||||
pid_t playerPid = -1;
|
||||
|
||||
std::mt19937 rng;
|
||||
};
|
||||
|
||||
} // namespace audio
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue