space-game001/src/dialogue/DialogueSystem.h
Vladislav Khorev 25bb79fb42 police chase
2026-04-19 08:22:03 +03:00

55 lines
1.4 KiB
C++

#pragma once
#include "dialogue/DialogueOverlay.h"
#include "dialogue/DialogueRuntime.h"
#include <Eigen/Dense>
#include <SDL.h>
#include <functional>
#include <string>
#include <vector>
namespace ZL::Dialogue {
struct TriggerZone {
std::string id;
std::string dialogueId;
Eigen::Vector3f center = Eigen::Vector3f::Zero();
float radius = 1.5f;
bool once = true;
bool triggered = false;
};
class DialogueSystem {
public:
bool init(Renderer& renderer, const std::string& zipFile = "");
bool loadDatabase(const std::string& path);
void update(int deltaMs, const Eigen::Vector3f& playerPosition);
void draw(Renderer& renderer);
bool handleKeyDown(SDL_Keycode key);
void handlePointerDown(float x, float y);
void handlePointerMoved(float x, float y);
bool handlePointerReleased(float x, float y);
bool startDialogue(const std::string& dialogueId, std::function<void()> onFinished = nullptr);
void stopDialogue();
bool isActive() const { return runtime.isActive(); }
bool blocksGameplayInput() const { return runtime.isActive(); }
void setFlag(const std::string& name, int value) { runtime.setFlag(name, value); }
int getFlag(const std::string& name) const { return runtime.getFlag(name); }
void addTriggerZone(const TriggerZone& zone);
void clearTriggerZones();
private:
DialogueDatabase database;
DialogueRuntime runtime;
DialogueOverlay overlay;
std::vector<TriggerZone> triggerZones;
};
} // namespace ZL::Dialogue