Added sounds

This commit is contained in:
Vladislav Khorev committed 2026-07-07 23:05:01 +03:00
1 parent c6ba8bd008
commit 124208f2a4
26 files changed
+210 -36

No files matched your search

+13 -2
View File
@@ -419,6 +419,17 @@ void Character::update(int64_t deltaMs, const CharacterResolver& resolver) {
state.currentState == AnimationState::ACTION_ATTACK_2)) {
if (attackTarget != nullptr) {
attackTarget->applyDamage(10.f, attackDirectionToTarget());
if (audioPlayer) {
if (state.isPlayer)
{
audioPlayer->playSoundAsync("audio/547041__cogfirestudios__hit-swing-sword-small-3.ogg");
}
else
{
audioPlayer->playSoundAsync("audio/13925__adcbicycle__21.ogg");
}
}
}
}
@@ -1176,8 +1187,8 @@ void Character::drawNightCpuWithShadow(Renderer& renderer,
void Character::setupHitSparks(std::shared_ptr<Texture> sparkTexture) {
hitSparkEmitter.setTexture(sparkTexture);
hitSparkEmitter.setShaderProgramName("spark");
hitSparkEmitter.setMaxParticles(64);
hitSparkEmitter.setParticleSize(0.08f);
hitSparkEmitter.setMaxParticles(128);
hitSparkEmitter.setParticleSize(0.02f);
hitSparkEmitter.setBiasX(0.0f);
hitSparkEmitter.setEmissionRate(1.0e9f);
hitSparkEmitter.setSpeedRange(2.0f, 4.0f);
+2
View File
@@ -12,6 +12,7 @@
#include <vector>
#include <unordered_map>
#include "dialogue/TranslationDatabase.h"
#include "AudioPlayerAsync.h"
namespace ZL {
@@ -107,6 +108,7 @@ public:
std::string weaponAttachBoneName = "RightHand";
SparkEmitter hitSparkEmitter;
AudioPlayerAsync* audioPlayer;
static Dialogue::TranslationDatabase nameTranslations;
+6 -4
View File
@@ -16,7 +16,6 @@
#include <android/log.h>
#endif
#ifdef EMSCRIPTEN
#include <emscripten.h>
#endif
@@ -258,10 +257,12 @@ namespace ZL
menuManager.onItemPickedUp(itemId);
const Item* item = ItemRegistry::instance().findById(itemId);
if (item) menuManager.showToast(menuManager.toastTextureItemAdded, item->name);
audioPlayer->playSoundAsync("audio/831642__ienba__generic-game-pick-up.ogg");
};
gameState.inventory.onItemRemoved = [this](const std::string& itemId) {
const Item* item = ItemRegistry::instance().findById(itemId);
if (item) menuManager.showToast(menuManager.toastTextureItemRemoved, item->name);
audioPlayer->playSoundAsync("audio/831642__ienba__generic-game-pick-up.ogg");
};
// Wire phone dialogue start function so MenuManager can trigger dialogues.
@@ -433,7 +434,7 @@ namespace ZL
uniInteriorParams.playerPosition = Eigen::Vector3f(0.942694, 0, -9.63104);
gameState.locations["uni_interior"] = std::make_shared<Location>(renderer, gameState.inventory);
gameState.locations["uni_interior"]->setup(uniInteriorParams, &gameState.questJournal);
gameState.locations["uni_interior"]->setup(uniInteriorParams, &gameState.questJournal, audioPlayer.get());
gameState.locations["uni_interior"]->scriptEngine.setGlobalStore(&gameState.globalInts);
gameState.locations["uni_interior"]->scriptEngine.setGlobalFloatStore(&gameState.globalFloats);
gameState.locations["uni_interior"]->requestNightDayTransition = [this](bool isNight, bool isDawn) { gameState.isNight = isNight; gameState.isDawn = isDawn; };
@@ -487,7 +488,7 @@ namespace ZL
gameState.locations["uni_exterior"] = std::make_shared<Location>(renderer, gameState.inventory);
gameState.locations["uni_exterior"]->setup(uniExteriorParams, &gameState.questJournal);
gameState.locations["uni_exterior"]->setup(uniExteriorParams, &gameState.questJournal, audioPlayer.get());
gameState.locations["uni_exterior"]->scriptEngine.setGlobalStore(&gameState.globalInts);
gameState.locations["uni_exterior"]->scriptEngine.setGlobalFloatStore(&gameState.globalFloats);
gameState.locations["uni_exterior"]->requestNightDayTransition = [this](bool isNight, bool isDawn) {
@@ -547,7 +548,7 @@ namespace ZL
params_dorm.playerPosition = Eigen::Vector3f(6.76345, 0, -14.6022);
gameState.locations["location_dorm"] = std::make_shared<Location>(renderer, gameState.inventory);
gameState.locations["location_dorm"]->setup(params_dorm, &gameState.questJournal);
gameState.locations["location_dorm"]->setup(params_dorm, &gameState.questJournal, audioPlayer.get());
gameState.locations["location_dorm"]->scriptEngine.setGlobalStore(&gameState.globalInts);
gameState.locations["location_dorm"]->scriptEngine.setGlobalFloatStore(&gameState.globalFloats);
gameState.locations["location_dorm"]->requestNightDayTransition = [this](bool isNight, bool isDawn) { gameState.isNight = isNight; gameState.isDawn = isDawn; };
@@ -1482,6 +1483,7 @@ namespace ZL
bool Game::startDarklandsTransition()
{
audioPlayer->playSoundAsync("audio/459618__n-lerche__blow.ogg");
if (!gameState.isNight)
{
currentLocation()->dialogueSystem.startDialogue("darklands_day_dialog001");
+4 -2
View File
@@ -83,7 +83,7 @@ namespace ZL
// ---- Setup ----
void Location::setup(const LocationSetup& params, Quest::QuestJournal* journal)
void Location::setup(const LocationSetup& params, Quest::QuestJournal* journal, AudioPlayerAsync* audioPlayer)
{
// Load static game objects
@@ -138,6 +138,7 @@ namespace ZL
player->state.position = params.playerPosition;
player->setTarget(params.playerPosition);
player->setupHitSparks(sparkTexture);
player->audioPlayer = audioPlayer;
std::cout << "Load resurces step 9" << std::endl;
// Load NPCs from JSON. Aggressive (canAttack) NPCs need a player target
@@ -149,6 +150,7 @@ namespace ZL
npc->state.homePosition = Eigen::Vector3f(npc->state.position.x(), 0.f, npc->state.position.z());
if (npc->state.canAttack) {
npc->setupHitSparks(sparkTexture);
npc->audioPlayer = audioPlayer;
npc->state.attackTargetIndex = CharacterState::kPlayerIndex;
}
}
@@ -179,7 +181,7 @@ namespace ZL
npcNameText.reset();
}
scriptEngine.init(this, &inventory, params.scriptPath);
scriptEngine.init(this, &inventory, audioPlayer, params.scriptPath);
scriptEngine.setQuestJournal(journal);
dialogueSystem.setOnCutsceneFinished([this](const std::string& cutsceneId) {
+2 -1
View File
@@ -133,7 +133,7 @@ namespace ZL
bool playBattleMusic = false;
void setup(const LocationSetup& params, Quest::QuestJournal* journal);
void setup(const LocationSetup& params, Quest::QuestJournal* journal, AudioPlayerAsync* audioPlayer);
void setupNavigation(const std::vector<std::string>& paths);
bool switchNavigation(int index);
InteractiveObject* raycastInteractiveObjects(const Eigen::Vector3f& rayOrigin, const Eigen::Vector3f& rayDir);
@@ -170,6 +170,7 @@ namespace ZL
friend class LocationEditor;
Renderer& renderer;
Inventory& inventory;
AudioPlayerAsync* audioPlayer;
private:
// ---- Pointer-to-index helpers ----
+60 -1
View File
@@ -331,25 +331,32 @@ namespace ZL {
uiManager.replaceRoot(mainMenuRoot);
uiManager.setTextButtonCallback("menuStartButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
enterGameplay();
});
uiManager.setTextButtonCallback("menuAboutButton", [this](const std::string&) {
showAboutScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("menuSettingsButton", [this](const std::string&) {
showSettingsScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("menuLanguageButton", [this](const std::string&) {
showLanguageScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("menuLoadButton", [this](const std::string&) {
showLoadGameScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
#ifndef EMSCRIPTEN
uiManager.setTextButtonCallback("menuExitButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
Environment::exitGameLoop = true;
});
#else
@@ -362,6 +369,7 @@ namespace ZL {
uiManager.setTextButtonCallback("aboutBackButton", [this](const std::string&) {
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
}
@@ -371,6 +379,7 @@ namespace ZL {
saveSettings();
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
// Set initial slider positions before registering callbacks so
@@ -456,6 +465,7 @@ namespace ZL {
uiManager.setTextButtonColor("musicToggleButton", on
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("soundToggleButton", [this](const std::string&) {
audioPlayer_.setSoundEnabled(!audioPlayer_.isSoundEnabled());
@@ -464,10 +474,12 @@ namespace ZL {
uiManager.setTextButtonColor("soundToggleButton", on
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("fullScreenToggleButton", [this, refreshFullscreenToggle](const std::string&) {
Environment::setFullscreen(!Environment::isFullscreen);
refreshFullscreenToggle();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
}
@@ -477,14 +489,17 @@ namespace ZL {
saveSettings();
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setTextButtonCallback("languageRussianButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
ZL::g_currentLanguage = ZL::Language::Russian;
reloadLocalizedGameContent();
saveSettings();
});
uiManager.setTextButtonCallback("languageEnglishButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
ZL::g_currentLanguage = ZL::Language::English;
reloadLocalizedGameContent();
saveSettings();
@@ -528,6 +543,7 @@ namespace ZL {
uiManager.setTextButtonCallback("loadBackButton", [this](const std::string&) {
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
static const char* kSlotButtons[4] = {
@@ -543,6 +559,7 @@ namespace ZL {
uiManager.setTextButtonText(kSlotButtons[i], label);
}
uiManager.setTextButtonCallback(kSlotButtons[i], [this, slot](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
if (onLoadGame) onLoadGame(slot);
enterGameplay(true);
});
@@ -555,6 +572,7 @@ namespace ZL {
uiManager.setTextButtonCallback("saveBackButton", [this](const std::string&) {
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
static const char* kSlotButtons[4] = {
@@ -578,6 +596,7 @@ namespace ZL {
? "Empty"
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + "\n" + info.savedAt;
uiManager.setTextButtonText(buttonName, label);
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
}
});
}
@@ -607,6 +626,7 @@ namespace ZL {
}
uiManager.setButtonCallback(btnName, [this, i](const std::string&) {
selectInventoryItem(i);
audioPlayer_.playSoundAsync("audio/sound_bag001.ogg");
});
} else {
uiManager.setNodeVisible(btnName, false);
@@ -617,6 +637,8 @@ namespace ZL {
if (!portrait && !items.empty()) {
selectInventoryItem(0);
}
audioPlayer_.playSoundAsync("audio/sound_bag_open.ogg");
}
void MenuManager::selectInventoryItem(int index) {
@@ -668,6 +690,7 @@ namespace ZL {
for (int i = 0; i < inventoryMenuStackDepth_; ++i) uiManager.popMenu();
inventoryMenuStackDepth_ = 0;
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/sound_bag_close.ogg");
}
void MenuManager::openQuestJournal() {
@@ -683,6 +706,7 @@ namespace ZL {
uiManager.setButtonCallback("journalExitButton", [this](const std::string&) {
closeQuestJournal();
audioPlayer_.playSoundAsync("audio/656126__itsthegoodstuff__paging-through-book.ogg");
});
static const char* kItemNames[9] = {
@@ -693,6 +717,7 @@ namespace ZL {
for (int i = 0; i < 9; ++i) {
uiManager.setTextButtonCallback(kItemNames[i], [this, i](const std::string&) {
selectQuestByIndex(i);
audioPlayer_.playSoundAsync("audio/255571__stradie__flipping-paper.ogg");
});
}
@@ -700,6 +725,8 @@ namespace ZL {
if (!portrait && !visibleQuestIds.empty()) {
selectQuestByIndex(0);
}
audioPlayer_.playSoundAsync("audio/255571__stradie__flipping-paper.ogg");
}
void MenuManager::closeQuestJournal() {
@@ -750,19 +777,24 @@ namespace ZL {
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
closePhoneEntirely();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
uiManager.setButtonCallback("phoneMessenger", [this](const std::string&) {
openPhoneMessenger();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneBank", [this](const std::string&) {
openPhoneBank();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneVideo", [this](const std::string&) {
openPhoneVideo();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneTaxi", [this](const std::string&) {
openPhoneTaxi();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
if (gameState_.isNight)
@@ -786,6 +818,8 @@ namespace ZL {
uiManager.setNodeVisible("phoneTimeNight", false);
uiManager.setNodeVisible("phoneTimeDawn", false);
}
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
}
void MenuManager::openPhoneMessenger() {
@@ -803,19 +837,23 @@ namespace ZL {
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
closePhoneEntirely();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
uiManager.setTextButtonCallback("chat1button", [this](const std::string&) {
gameState_.chatUnread[0] = false;
openPhoneChatFromList(0, isPortraitMode() ? verticalPhoneChat1Root : phoneChat1Root);
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setTextButtonCallback("chat2button", [this](const std::string&) {
gameState_.chatUnread[1] = false;
openPhoneChatFromList(1, isPortraitMode() ? verticalPhoneChat2Root : phoneChat2Root);
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setTextButtonCallback("chat3button", [this](const std::string&) {
gameState_.chatUnread[2] = false;
openPhoneChatFromList(2, isPortraitMode() ? verticalPhoneChat3Root : phoneChat3Root);
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
}
@@ -851,11 +889,13 @@ namespace ZL {
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
closePhoneEntirely();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
uiManager.setButtonCallback("buttonBack", [this](const std::string&) {
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
}
@@ -865,15 +905,16 @@ namespace ZL {
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
closePhoneEntirely();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
uiManager.setButtonCallback("buttonBack", [this](const std::string&) {
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("videoSkip", [this](const std::string&) {
closePhoneEntirely();
if (gameState_.isNight)
{
startDialogueFunc("dialog_video002");
@@ -887,6 +928,7 @@ namespace ZL {
}
else
{
audioPlayer_.playSoundAsync("audio/78564__joedeshon__alarm_clock_ticking_02.ogg");
startNightTransitionFunc();
}
}
@@ -911,11 +953,13 @@ namespace ZL {
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
closePhoneEntirely();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
uiManager.setButtonCallback("buttonBack", [this](const std::string&) {
uiManager.popMenu();
uiManager.updateAllLayouts();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("mapGo", [this](const std::string&) {
gameState_.tutorialNeedOpenTaxiScreen = false;
@@ -927,7 +971,10 @@ namespace ZL {
gameState_.money -= 500;
closePhoneEntirely();
if (startDialogueFunc) startDialogueFunc("dialog_taxi002");
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
}
void MenuManager::openPhoneChatFromList(int chatIndex, std::shared_ptr<UiNode> chatRoot) {
@@ -967,10 +1014,12 @@ namespace ZL {
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
closePhoneScreenFromChat();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
uiManager.setTextButtonCallback("chatTitleButton", [this](const std::string&) {
returnToPhoneChatList();
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
});
if (chatOpenCallback) {
@@ -1054,30 +1103,37 @@ namespace ZL {
}
void MenuManager::showModalMenuScreen() {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
uiManager.pushMenuFromSavedRoot(modalMenuRoot);
uiManager.setButtonCallback("modalExitButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
uiManager.popMenu();
uiManager.updateAllLayouts();
});
uiManager.setButtonCallback("menuCloseButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
uiManager.popMenu();
uiManager.updateAllLayouts();
});
uiManager.setButtonCallback("menuSaveButton", [this](const std::string&) {
showSaveGameScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setButtonCallback("menuLoadButton", [this](const std::string&) {
showLoadGameScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setButtonCallback("menuSettingsButton", [this](const std::string&) {
showSettingsScreen();
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
});
uiManager.setButtonCallback("menuExitButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
uiManager.popMenu();
showMainMenu();
});
@@ -1441,6 +1497,7 @@ namespace ZL {
uiManager.setButtonCallback("inventoryExitButton", [this](const std::string&) {
closePortraitInventoryItem();
audioPlayer_.playSoundAsync("audio/sound_bag001.ogg");
});
const auto& item = items[index];
@@ -1468,6 +1525,7 @@ namespace ZL {
uiManager.setButtonCallback("journalItemExitButton", [this](const std::string&) {
closePortraitJournalItem();
audioPlayer_.playSoundAsync("audio/255571__stradie__flipping-paper.ogg");
});
Quest::QuestState* quest = gameState_.questJournal.findQuest(visibleQuestIds[index]);
@@ -1656,6 +1714,7 @@ namespace ZL {
recomputePhoneChatPositions();
}
chatUiManager.startPopIn(nodeName, 300.0f);
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
}
void MenuManager::setDarklandsMode(bool enabled)
+9 -1
View File
@@ -33,7 +33,7 @@ namespace ZL {
ScriptEngine::ScriptEngine() = default;
ScriptEngine::~ScriptEngine() = default;
void ScriptEngine::init(Location* loc, Inventory* inventory, const std::string& scriptPath) {
void ScriptEngine::init(Location* loc, Inventory* inventory, AudioPlayerAsync* audioPlayer, const std::string& scriptPath) {
impl = std::make_unique<Impl>();
sol::state& lua = impl->lua;
@@ -773,6 +773,14 @@ namespace ZL {
}
});
api.set_function("play_sound",
[audioPlayer](const std::string& soundPath) -> void {
if (audioPlayer)
{
audioPlayer->playSoundAsync(soundPath);
}
});
lua.script_file(scriptPath);
}
+2 -1
View File
@@ -5,6 +5,7 @@
#include "quest/QuestJournal.h"
#include "external/nlohmann/json.hpp"
#include "ISaveable.h"
#include "AudioPlayerAsync.h"
namespace ZL {
@@ -17,7 +18,7 @@ public:
~ScriptEngine();
// Must be called once, after the Game's NPCs are ready.
void init(Location* game, Inventory* inventory, const std::string& scriptPath);
void init(Location* game, Inventory* inventory, AudioPlayerAsync* audioPlayer, const std::string& scriptPath);
// Execute a Lua script file. Logs errors to stderr.
void runScript(const std::string& path);